CCI

How far price is from its recent average, measured against its usual deviation.

Commodity Channel Index = (x − SMA(x)) ÷ (constant × mean deviation), SMA and mean absolute deviation over the last length values (current included); x defaults to the typical price hlc3. A flat window (mean deviation 0) is not ready. Mirror: signed (a mirrored price flips the deviation from the average).

Settings

SettingDefaultRangeWhat it does
length202 to 500Values in the window.
constant0.0150.0001 to 1Lambert's scaling constant.

What it gives

OutputWhat it is
cciCCI, unbounded.

What it reads

It reads open, high, low, close, hl2, hlc3, ohlc4, hlcc4, hlc3 by default.

Warm-up

With its default settings, CCI needs 20 closed candles before its first value. A backtest loads them before its start date, so the first trade can already use it.

Test it

Copy this sentence into the Algonney chat to backtest it:

Backtest a strategy on BTC that uses CCI with its default settings