Bollinger Bands®
Bollinger Bands were created by John A. Bollinger. They compare volatility and relative price levels over a period time. The indicator consists of three bands designed to encompass the majority of a security's price action: a Moving Average in the middle, an upper band (moving average plus x standard deviations) and a lower band (moving average minus x standard deviations).
Since the bands encompass normal price behavior, it is possible to identify abnormal price levels; the bands squeeze together when volatility is low and spread apart when volatility is high.
Simple Function Version 
Top 
BBTOP(d, x, z) 
x =Period, d =StdDev, z =Offset 
Bottom 
BBBOT(d, x, z) 

Center 
AVG(Cz, x) 

Width 
2 * d * STDDEV(x, z) 

Simple Indicator Version 
Top 
BBTOPd.x.z 

Bottom 
BBBOTd.x.z 

Center 
AVGCx.z 

Width 
2 * d * STDDEVx.z 

Other Average Types of Price  Top 
tAVGCx.z + d * STDDEVx.z 
x =Period, d =StdDev, z =Offset, t =AverageType 
Bottom 
tAVGCx.z  d * STDDEVx.z 

Center 
tAVGCx.z 

Width 
2 * d * STDDEVx.z 

Generalized Version  Top  tAVG(w, x) + d * SQR(ABS(SUM((w) ^ 2, x)  x * AVG(w, x) ^ 2) / x) 
w =Formula, x =Period, d =StdDev, t =AverageType 
Bottom 
tAVG(w, x)  d * SQR(ABS(SUM((w) ^ 2, x)  x * AVG(w, x) ^ 2) / x) 

Center 
tAVG(w, x) 

Width 
2 * d * SQR(ABS(SUM((w) ^ 2, x)  x * AVG(w, x) ^ 2) / x) 
Width should not be confused with the Bollinger Bandwidth indicator. The width from the table above is the actual distance between the top and bottom bands. In the Bollinger BandWidth indicator, this value is divided by the value of the centerline.
Where w
is any formula which returns a numeric value.
Where x
is the period which must be an an integer.
Where d
is the width of the distance of the bands from the centerline in standard deviations and can be any numeric value in the function version, but must be an integer in the indicator version.
Where z
is the offset. An offset of 1 is 1 bar ago.
Where t
is the average type. Leave blank for simple, set to X for exponential, F for front weighted, and H for Hull.
Examples
The value of the upper Bollinger Band 20, 2.00 can be written as follows.
BBTOP(2, 20, 0)
But you can leave out the offset setting for the current bar since it is zero.
BBTOP(2, 20)
The lower Bollinger Band just changes TOP to BOT.
BBBOT(2, 20)
Read more about Bollinger Bands at www.BollingerBands.com.
Bollinger Bands® are the registered trademark of John Bollinger, who developed them.