Sidechair

ta.bb()

Browse the reference

Returns the Bollinger Bands as three series: the moving-average basis and the bands mult standard deviations above and below it.

Try it in the editor

ta.bb returns [basis, upper, lower]. The basis is ta.sma(series, length), and each band sits mult times the window's standard deviation away. The deviation is the population form, dividing by length.

The first values appear on bar number length. Capture the tuple with three names: [mid, upper, lower] = ta.bb(close, 20, 2).

Syntax

Pine Script
ta.bb(series: series int/float, length: series int, mult: simple int/float) -> [series float, series float, series float]

Arguments

NameTypeDefaultDescription
seriesseries int/floatrequiredSeries the bands are built on, usually close.
lengthseries intrequiredWindow length for the average and the deviation. A whole number of 1 or more.
multsimple int/floatrequiredNumber of standard deviations between the basis and each band.

Returns

[series float, series float, series float]: the basis, the upper band and the lower band.

Remarks

  • The bands widen in volatile stretches and narrow in quiet ones; ta.bbw tracks that width.

Example

Pine ScriptBollinger Bands with a fillOpen in editor
//@version=6
indicator("Bollinger Bands", overlay = true)
[mid, upper, lower] = ta.bb(close, 20, 2)
plot(mid, "Basis", color = color.orange)
p1 = plot(upper, "Upper", color = color.blue)
p2 = plot(lower, "Lower", color = color.blue)
fill(p1, p2, color = color.new(color.blue, 90), title = "Band area")

See also

Runs on Sidechair