Bollinger Bands Formula tutorial cover

Bollinger Bands Formula and Calculation

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email
Table of Contents

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

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)

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:

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.

More from Finance Strategy System

ATR with BOLLINGER BANDS – EASYLANGUAGE

Bollinger Bands Indicator Volatility Breakout and Squeeze

The Bollinger Bands Indicator Tutorial

Bollinger Bands Indicator Essential Tutorial for Dummies

Bollinger Bands Standard Deviation

The American Association of Individual Investors (AAII)

All about the Trend in Technical Analysis || Essential Tutorial

Gold Trading Strategy with Stochastic Indicator

The TRIX || Triple Exponential Average Indicator || Tutorial

The VIX Essential Tutorial || S&P500 Implied Volatility Index

ABOUT US

logo homepage finance strategy system

 Financial Strategy System was   created to share what we have   learned in the last 11 years in   the market.

 In this site we talk about trading,   finance, trading platform,   strategies, indicators,   automated trading systems and   programming.

 You can find dozens of free   tutorials and many technical   indicators to download for free.

error: Alert: Content is protected !!