bb_width
Bollinger Bands Width (upper_band - lower_band)
bb_width(source, period, num_stdev)
Parameters
| Name | Type | Description |
|---|---|---|
source |
field | Data series |
period |
int | Stdev period |
num_stdev |
float | Number of standard deviations |
Formula
BB Width = 2 * num_stdev * stdev(source, 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
Range
period must be 2-400
Notes
Absolute width -- the two bands' moving averages cancel, so this takes no matype: it has no MA term to select one for