Skip to content

BollingerBands


class backtide.indicators.BollingerBands(period=20, std_dev=2.0)

Bollinger Bands (BB).

Volatility bands placed above and below an n-period SMA. The bands widen during high volatility and contract during low volatility. Useful for volatility assessment, mean-reversion strategies, and breakout detection when price moves outside the bands.

Formula:

\[ \begin{aligned} Upper_t &= SMA_t + k \cdot \sigma_t \\\\ Lower_t &= SMA_t - k \cdot \sigma_t \end{aligned} \]

where \(\sigma_t\) is the rolling standard deviation over \(n\) periods. Read more on Wikipedia.

Parameters

period : int, default=20

Number of bars for the moving average.

std_dev : float, default=2.0
Number of standard deviations.

Attributes

acronym : str

Short ticker-style acronym.

name : str
Human-readable indicator name.


See Also

AverageTrueRange

Average True Range (ATR).

CommodityChannelIndex

Commodity Channel Index (CCI).

SimpleMovingAverage

Simple Moving Average (SMA).


Methods

compute Compute the indicator on a dataset.
description Short explanation of what the indicator measures.


method backtide.indicatorscompute(data)

Compute the indicator on a dataset.

Parameters

data : np.ndarray | pd.DataFrame | pl.DataFrame

Historical OHLCV data.

Returns

np.ndarray | pd.Series | pl.Series | pd.DataFrame | pl.DataFrame

The computed values. For multi-output indicators (e.g., upper and lower bounds), return a 2d structure.



method backtide.indicatorsdescription()

Short explanation of what the indicator measures.

Returns

str

The description.