Are you searching for the Bollinger Bands Formula? you found it!

You can perform the Bollinger Bands calculation using the following formula.

 

 

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 ;

 

 

The Bollinger Bands code for MetaStock:

 

Basic formula:
bb = (close – lower band) / (Upper band – lower band)

{The upper band}
upper:=2*Stdev( CLOSE,20 ) + Mov(CLOSE,20,SIMPLE);
{The lower band}
lower:=Mov(CLOSE,20,SIMPLE)-2*Stdev( CLOSE,20);
{bb}
percb:=(C-lower)/(upper-lower)*100;
percb

 

 

 

 

 

 

 

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.

1-bollinger-bands-formula-article

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.

 

 

 

We created a custom indicator that shows the volatility phases:

Bollinger-Bands-BandWidth-TradeStation-MultiCharts

You can find it in this post.

 

 

Leave a Reply