Skip to content

CommodityChannelIndex


class backtide.indicators.CommodityChannelIndex(period=20)

Commodity Channel Index (CCI).

Measures how far the typical price deviates from its statistical mean, identifying cyclical trends. Values above +100 suggest overbought conditions; below -100, oversold. Useful for identifying cyclical price patterns, spotting divergences, and timing entries in commodities and equities.

Formula:

\[ \begin{aligned} TP_t &= \frac{H_t + L_t + C_t}{3} \\\\ CCI_t &= \frac{TP_t - SMA_n(TP_t)}{0.015 \cdot MD_t} \end{aligned} \]

where \(MD_t\) is the mean absolute deviation of \(TP\) over \(n\) periods. Read more on Wikipedia.

Parameters

period : int, default=20

Look-back window length.

Attributes

acronym : str

Short ticker-style acronym.

name : str
Human-readable indicator name.


See Also

BollingerBands

Bollinger Bands (BB).

RelativeStrengthIndex

Relative Strength Index (RSI).

StochasticOscillator

Stochastic Oscillator (STOCH).


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.