Commodity channel index
All indicators

LibraryMomentum

Indicator

Commodity channel index

How far the typical price is from its average, in units of its mean deviation, scaled so that most values fall between -100 and 100.

MomentumOwn pane1 inputCCI

How it is calculated

The typical price is (high + low + close) / 3. CCI is the typical price minus its SMA over the length, divided by 0.015 times the mean absolute deviation of the typical prices from that SMA. It is 0 when the price sits on its average, when the deviation is zero, and for a window of identical prices. As TA-Lib CCI, after Lambert 1980.

Reference: TA-Lib CCI (Lambert 1980)

How to read it

Above 100 price is unusually high against its average, below -100 unusually low. It has no fixed bounds, so values of 200 or more occur in strong moves. Lambert took a rise above 100 as the start of a trend; others read the same levels as overbought and oversold. A zero crossing shows price passing its average.

In a strategy

A breakout entry when CCI rises above 100 and an exit when it falls back below: ctx.ind("cci", length=20) compared with its value a bar earlier.

Inputs

InputTypeDefaultRange or choices
LengthlengthWhole number20min 2, max 5000

What it draws

LineDrawn as
CCILine

Guide lines at -100, 100.

Used in

No strategy template reads it yet.

OrionQuant