Sidechair

ta.bbw()

Browse the reference

Returns the Bollinger Band width: the gap between the upper and lower band divided by the basis.

Try it in the editor

ta.bbw is (upper - lower) / basis for ta.bb with the same arguments. Dividing by the basis makes the number comparable across price levels.

Low readings mark a squeeze, high readings mark expansion. Early bars, before the average has length values, return na.

Syntax

Pine Script
ta.bbw(series: series int/float, length: series int, mult: simple int/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: the relative band width, or na while the window is not full.

Remarks

  • The width equals 2 * mult * stdev / basis.

Example

Pine ScriptSqueeze detectorOpen in editor
//@version=6
indicator("Band width")
w = ta.bbw(close, 20, 2)
plot(w, "BBW", color = color.blue)
plot(ta.lowest(w, 100), "100-bar low", color = color.red)

See also

Runs on Sidechair