Contents
- abs
- add
- all_time_high
- all_time_low
- and
- approx
- aroon_down
- aroon_osc
- aroon_up
- atr
- bb_lower
- bb_upper
- bb_width
- cci
- change
- cond
- count
- cross
- crossover
- crossunder
- cumsum
- days_since
- dev
- deviation
- div
- ema
- eq
- falling
- floordiv
- gain
- gt
- gte
- highest
- highest_bars_ago
- hma
- kc_lower
- kc_middle
- kc_upper
- kcw
- loss
- lowest
- lowest_bars_ago
- lt
- lte
- macd_histogram
- macd_line
- macd_signal
- max
- mean
- median
- mfi
- min
- mod
- mom
- months_since
- mul
- ne
- obv
- offset
- or
- pct_change
- percentrank
- pivothigh
- pivotlow
- pow
- range
- rising
- roc
- rsi
- sma
- sqrt
- stdev
- stoch_d
- stoch_k
- streak
- sub
- sum
- swma
- true_range
- universe_percentile
- variance
- vwma
- weeks_since
- wilderma
- williams_r
- wma
- years_since
No matches
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