bb_width

Bollinger Bands Width (upper_band - lower_band)

bb_width(source, period, num_stdev, matype="sma")

Parameters

Name Type Description
source field Data series
period int MA and stdev period (commonly 20)
num_stdev float Standard deviations (commonly 2.0)
matype str, optional MA type ["sma", "ema", "wma", "wilder"], default "sma"

Formula

```
BB_Width = BB_Upper - BB_Lower
         = 2 * num_stdev * STDEV(field, period)
```

Examples

/* narrower bands (lower volatility) than 20 bars ago */
bb_width(close, 20, 2) < bb_width(close, 20, 2)[20];

/* wider bands (higher volatility) than 20 bars ago */
bb_width(close, 20, 2) > bb_width(close, 20, 2)[20];

/* increasing width (expanding volatility) for 3 consecutive bars */
rising(bb_width(close, 20, 2), 3) == true;

/* decreasing width (contracting volatility) for 3 consecutive bars */
falling(bb_width(close, 20, 2), 3) == true;

Returns

Float (band width) ## See Also bb_upper, bb_lower