Investment Studio > Expressions > Functions > Indicator > BOL

float array[*][4] bol(float array[*][2] dc, integer days = 20, float sigma = 2)

Returns a four-column array containing dates and corresponding Bollinger band values. Each row is structured as follows:

Column # Content
1 The quote date.
2 The lower Bollinger band value.
3 The central Bollinger band value.
4 The upper Bollinger band value.

Given n input rows in dc, n - days + 1 rows are returned.

dc is a two-column array containing dates (first column) and corresponding daily closing prices (second column). The array is assumed to be time-sorted, with earlier dates preceding later dates.

If daily highs and closes are available, you may also want to consider Keltner bands.

Automatic type conversion allows the use of date strings as arguments instead of explicit date values.

days > 0 is the length of the time frame, i.e. the number of trading days contributing to the calculation of each day's Bollinger band values. If omitted, days defaults to 20.

sigma is the number of standard deviations (as computed by stdevp) by which the upper and lower Bollinger bands are separated from the central band. If omitted, sigma defaults to 2.

Interpretation

Bollinger bands are a moving average (see MA) crossed with a volatility indicator.

The central band is just MA(days).
The daily upper band value is obtained by adding sigma standard deviations of the price, computed from the latest days closes, to the central band value.
The daily lower band value is obtained by subtracting sigma standard deviations of the price, computed from the latest days closes, from the central band value.

The result is an adaptive envelope: it widens when price action becomes volatile and contracts when prices settle down.

Consider for instance Motorola (NYSE:MOT) from June 1 to December 31, 2001:

The chart shows Bollinger bands (20 days, 2 standard deviations) superimposed on prices. Note how prices tend to gravitate to the lower band in downtrends and to the upper band in uptrends.

The creator of Bollinger bands, John Bollinger, emphasized the following properties of his invention, all illustrated to some extent by the above chart:

Sharp price moves tend to occur after periods of envelope contraction, i.e. of diminishing volatility.

This is rather circular, since sharp price moves are what causes the envelope to widen in the first price. It's equivalent to saying that rain tends to occur after periods of sunny weather.

Prices moving outside the bands tend to indicate that the current trend will continue.

See the July rally in the Motorola chart; but see also the counterexample provided by the September low.

A stronger version of this statement may be that prices moving outside the bands for the first time after crossing the central band tend to indicate that the current trend will continue. But even this statement has a counterexample in the Motorola chart, in the form of the November high.

Bottoms and tops outside the bands followed by bottoms and tops inside the bands tend to be followed by trend reversals.

In the Motorola chart, see July and August tops; September double-bottom; November and December tops.

A move originating at one outer band often goes all the way to the opposite band. This may be used to set price targets.

In the Motorola chart, see June low to July high to August low; September low to October high; November high to November low.

In fairness, Bollinger did state that his bands do not give buy or sell signals; rather, he viewed them as indicators of overbought and oversold conditions, and suggested using them in conjunction with RSI and OBV.

Example

Assuming standard US date format settings,

=bol({{"1/1/1990", 100}, {"1/2/1990", 110}, {"1/3/1990", 120}}, 2, 1)

returns {{32875, 100, 105, 110}, {32876, 110, 115, 120}}. Zooming in on the first row, 32875 is the date code for 1/2/1990; 100 is the lower band value, 105 the central band value and 110 the upper band value for that date (with days = 2 and sigma = 1).

See also atr, kb, ma, mi, rsi, obv, stdevp, tr, voi.