BollingerBand (Function)
The BollingerBand function calculates an n standard deviation (StdDev) line (usually 2 StdDevs) above or below a center-line simple moving average.
Syntax
BollingerBand(Price, Length, NumDevs)
Returns (Double)
A numeric value for the current bar.
Parameters
Name | Type | Description |
Price | Numeric | Specifies which bar value (price, function, or formula) to be considered for the center-line average. |
Length | Numeric | Sets the number of bars to consider for the center-line average. |
NumDevs | Numeric | Sets the number of standard deviations above (positive) or below (negative) the center-line average. |
Remarks
Normally BollingerBands are used with price data, but they can also be used with indicators and other calculated values.
The BollingerBand function can be interpreted in many ways and can be used in multiple time frames. The traditional interpretation would look for a bar to cross over one on the bands and then cross back over, signaling a potential market reversal.
The value for the Length input parameter should always be a positive whole number greater than 0.
The number of Standard Deviations represents the percentage of values that lie within the normal distribution range of values. At 2 standard deviations over 95 percent of all values lie within the normal distribution of values. At 3 standard deviations over 99 percent of all values lie within the normal distribution of values.
By using a number of standard deviations within the normal distribution range of values, the BollingerBand adjusts for price volatility.
Example
Assigns to Value1 the upper BollingerBand, and assigns to Value2 and plots the lower BollingerBand, for each bar based on 2 standard deviations a simple 20 bar average of the Close, then plots Value1 and Value2:
Value1 = BollingerBand(Close,20,2);
Value2 = BollingerBand(Close,20,-2);
Plot1(Value1, "UpperBB");
Plot2(Value2, "LowerBB");
Assigns to Value1 the upper BollingerBand, and assigns to Value2 and plots the lower BollingerBand, for each bar based on 2 standard deviations of a simple 5 bar average of the RSI, then plots Value1, Value2, and the RSI value:
Value1 = BollingerBand(RSI (Close,14),5,2);
Value2 = BollingerBand(RSI (Close,14),5,-2);
Plot1(Value1, "UpperBB");
Plot2(Value2, "LowerBB");
Plot3(RSI(Close,14, "RSI");
See Also
Reference
John Bollinger, CFA, President, Bollinger Capital Management, Inc. P.O. Box 3358, Manhattan Beach, CA 90266.