Are you using the Bollinger Bands? Do you know the Formula for calculation?

This indicator is very popular and many traders plot it in their charts.

Do you know how to calculate the value of the Bollinger Bands?

It’s very simple. You can perform the Bollinger Bands calculation using the following formula.

• Middle Band = 20-day simple moving average (SMA)
• Upper Band = 20-day SMA + (20-day standard deviation of price x 2)
• Lower Band = 20-day SMA – (20-day standard deviation of price x 2)

As you can see, the Bollinger Bands calculation using only a Simple Moving Average with 2 standard deviations.

Why an indicator based only on moving average is so popular?

Because using the standard deviations you could draw in a chart the price’s volatility expansion.

When volatility increase, the band’s distance widening and vice-versa.

In the same way, if you increase the standard deviation value, the Bollinger Bands widening.

In a range market the Bollinger Bands narrowings.

The common calculation is with 20 periods moving average and two standard deviations.

You can change these parameters and optimize for many instruments.

Remember that every time you choose a specific “custom set” for your indicator, you are overfitting your system.

The best practice is to find a set of parameters that works with many instruments in many markets.

Generally, the 20 periods and two standard deviations are good settings.

If you use multiple Bollinger Bands strategy, you can set three different Standard Deviations, for example, 1.5 – 2 – 3.

## The Bollinger Bands Formula for calculation in EasyLanguage is:

inputs:
double BollingerPrice ( Close ),
int Length( 10 ),
double NumDevsUp ( 2.0 ),
double NumDevsDn( -2.0 );

variables:
int Avg( 0 ),
double SDev( 0 ),
d ouble LowerBand( 0 ),
double UpperBand( 0 );

Avg = AverageFC( BollingerPrice, Length ) ;
SDev = StandardDev( BollingerPrice, Length, 1 ) ;
UpperBand = Avg + NumDevsUp * SDev ;
LowerBand = Avg + NumDevsDn * SDev ;

We created a custom indicator that shows the volatility phases:

You can find it in this post.