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

ParameterTypeDefaultBounds or optionsDescription
Time Periodinteger52…100000Number of bars used for the middle moving average and band calculation.
Upper Deviationnumber2-3e+37…3e+37Number of standard deviations used to place the upper band above the middle band.
Lower Deviationnumber2-3e+37…3e+37Number of standard deviations used to place the lower band below the middle band.
Moving Average TypeenumsmaSimple 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 T3TA-Lib moving average type used for the middle band.

Outputs

OutputTypeDescription
Upper BandnumberUpper Bollinger Band value for the bar.
Middle BandnumberMiddle moving-average band value for the bar.
Lower BandnumberLower 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

  1. Band width normalized by the middle band.
  2. Price position between the lower and upper bands.
  3. Change in width over several bars.
  4. 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.

Resources

Search documentation

Search across 46 documentation pages.