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
| Setting | Default | Range | What it does |
|---|---|---|---|
| length | 20 | 2 to 500 | Values in the window. |
| constant | 0.015 | 0.0001 to 1 | Lambert's scaling constant. |
What it gives
| Output | What it is |
|---|---|
| cci | CCI, 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