VolatilityPine Script v6

ta.bbw()

Bollinger Bands Width

The Bollinger Band Width is the difference between the upper and the lower Bollinger Bands divided by the middle band.

Syntax

Syntax
ta.bbw(series, length, mult) → series float

Arguments

ParameterTypeDescription
seriesseries int/floatSource series (typically price).
lengthseries intLength of the moving average and standard deviation window.
multsimple int/floatStandard deviation factor.

Returns

Bollinger Bands Width.

Remarks

na values in the source series are ignored.

Code Examples

Pine Script v6 Example
//@version=6
indicator("ta.bbw")

plot(ta.bbw(close, 5, 4), color=color.yellow)

// the same on pine
f_bbw(src, length, mult) =>
    float basis = ta.sma(src, length)
    float dev = mult * ta.stdev(src, length)
    (((basis + dev) - (basis - dev)) / basis) * 100

plot(f_bbw(close, 5, 4))

Trading Applications

Detect Bollinger Band squeezes for breakout anticipation

Measure relative volatility over time

Identify low-volatility consolidation periods

Trigger alerts when bandwidth reaches extreme levels

Related Functions

Frequently Asked Questions

Generate ta.bbw() Code with AI

Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.bbw() and other built-in functions instantly.