Bollinger Bands

Bollinger Bands are a simple moving average surrounded by standard deviations. You can specify the number of bars for the moving average, as well as the number of standard deviations.

The calculation is performed as follows:

Assume a 20 bar Bollinger band with 2 Deviations.

First, for each of the last 19 bars and the current bar, add each bar’s close, and then divide this figure by 20 (the number of Bollinger band bars) to get the simple moving average.

Next, for each of the last 19 bars and the current bar, subtract the above calculated simple moving average from the close and square this value.

Add the above calculated values, divide by 20, and then get the square root of this value to get the deviation value.

The upper Bollinger band will be the simple moving average plus 2 times the deviation value.

The middle Bollinger band will be the simple moving average.

The lower Bollinger band will be the simple moving average minus 2 times the deviation value.

**Reference: **None.