Overlap studies
Bollinger Bands
Upper, middle, and lower bands around a moving average.
- Engine
- TA-Lib
- Function
BBANDS- Input series
- close
- Outputs
- 3
How it works
BBANDS calculates a middle moving average and places upper and lower bands at configurable standard-deviation distances from that middle band. In TA-Lib, the default moving average type code is 0.
Use case
Use Bollinger Bands to represent relative price position and volatility expansion or compression around a moving-average baseline.
Parameters
| Parameter | Type | Default | Bounds or options | Description |
|---|---|---|---|---|
| Time Period | integer | 5 | 2…100000 | Number of bars used for the middle moving average and band calculation. |
| Upper Deviation | number | 2 | -3e+37…3e+37 | Number of standard deviations used to place the upper band above the middle band. |
| Lower Deviation | number | 2 | -3e+37…3e+37 | Number of standard deviations used to place the lower band below the middle band. |
| Moving Average Type | enum | sma | Simple Moving Average, Exponential Moving Average, Weighted Moving Average, Double Exponential Moving Average, Triple Exponential Moving Average, Triangular Moving Average, Kaufman Adaptive Moving Average, MESA Adaptive Moving Average, Triple Exponential Moving Average T3 | TA-Lib moving average type used for the middle band. |
Outputs
| Output | Type | Description |
|---|---|---|
| Upper Band | number | Upper Bollinger Band value for the bar. |
| Middle Band | number | Middle moving-average band value for the bar. |
| Lower Band | number | Lower Bollinger Band value for the bar. |
Reading the result
Bollinger Bands combine a moving center with dispersion-based upper and lower envelopes. The distance between the bands describes recent variability in the source scale; price position inside or outside the envelope describes an unusual move relative to the configured local window.
A band touch is not inherently a reversal. Strong trends can continue near one band, while narrow bands can precede either directional or non-directional expansion.
Useful derived features
- Band width normalized by the middle band.
- Price position between the lower and upper bands.
- Change in width over several bars.
- Direction and slope of the middle band.
Common mistakes
Do not assume the two deviation settings must be symmetric, and do not compare absolute band widths across differently priced assets without normalization. When the bands collapse or the denominator in a custom normalized feature approaches zero, handle that downstream edge case explicitly.
DataCat workflow notes
The indicator has multiple output columns. Resolve all mappings through indicator_definitions so a query does not confuse upper, middle, and lower outputs or rely on their visual order.