Bollinger Bands
All indicators

LibraryVolatility

Indicator

Bollinger Bands

A moving average with a band above and below it whose width follows the price's standard deviation, so the bands widen when price swings and narrow when it calms down.

VolatilityOn the price3 inputsBB

How it is calculated

The middle band is the simple moving average of the source over the length. The upper and lower bands are the middle plus and minus mult times the population standard deviation of the same prices (dividing by n, not n minus 1). The first value comes once the length is filled. As TA-Lib BBANDS, after Bollinger 1983.

Reference: TA-Lib BBANDS (Bollinger 1983)

How to read it

A close outside a band shows a strong move, not by itself a reversal; in a trend price can ride along the upper or lower band. Narrow bands (a squeeze) often come before a larger move without telling its direction. The middle band serves as a trend reference.

In a strategy

Mean reversion back toward the middle after a close below the lower band, or a breakout entry when price closes above ctx.ind("bb", length=20, mult=2.0).upper after a squeeze.

Inputs

InputTypeDefaultRange or choices
LengthlengthWhole number20min 2, max 5000
MultipliermultNumber2min 0.1, max 10
SourcesourcePrice"close"close, open, high, low, hl2, hlc3, ohlc4, hlcc4

What it draws

LineDrawn as
UpperLine
BasisLine
LowerLine

Used in

No strategy template reads it yet.

OrionQuant