BBANDS
BBANDS
Summary
Bollinger Bands: a moving-average middle band with upper and lower bands offset by a multiple of the standard deviation. Used to gauge relative price volatility.
Formula
where is the input series, the period, the moving-average type,
and , the upper and lower deviation multipliers.
Notes
- The defaults reproduce Bollinger's original definition: a 20-period SMA middle band with
. Any other is a TA-Lib generalisation. - sets where the envelope is centred; and set how wide it is. The two are
independent — depends only on the price window, so changing the middle band re-centres
the bands without resizing them.
Inputs
inReal— Input data series
Outputs
outRealUpperBand— Middle band plus nbDevUp standard deviationsoutRealMiddleBand— The moving averageoutRealLowerBand— Middle band minus nbDevDn standard deviations
Parameters
| Parameter | Type | Default | Accepted values | Description |
|---|---|---|---|---|
optInTimePeriod | integer | 20 | 2–100000 | Periods for the MA and standard deviation |
optInNbDevUp | real | 2 | any real | Standard-deviation multiplier for the upper band |
optInNbDevDn | real | 2 | any real | Standard-deviation multiplier for the lower band |
optInMAType | MAType | SMA (0) | any MAType | Moving-average type for the middle band |
MAType values: 0 SMA · 1 EMA · 2 WMA · 3 DEMA · 4 TEMA · 5 TRIMA · 6 KAMA · 7 MAMA · 8 T3 · 9 HMA · 10 DISABLED
Properties
Numerical Stability: Depends on MA Type — This function's default, SMA, is start-independent.
| Display Flags |
|---|
| ✅ Overlap Input i |
| ☐ Independent Y-Axis |
| ☐ Candlestick |
Implementation
TA-Lib Definition: bbands.c · bbands.yaml
| Native | File |
|---|---|
| C | ta_BBANDS.c |
| Rust | bbands.rs |
| Java | Core_BBANDS.java |
TA-Lib is also available for Python, R and more using a wrapper.
Aliases
Bollinger Bands
See Also
References
- John A. Bollinger, Bollinger on Bollinger Bands, McGraw-Hill Trade (ISBN 0071373683)