CCI¶
Indicators · Oscillators
Commodity Channel Index — mean-deviation oscillator.
The Commodity Channel Index measures how far price has stretched from its own statistical "normal." Despite the name it works on any market, not just commodities. When CCI runs to extreme positive or negative readings, price has wandered unusually far from its average — a setup for either a snap-back (mean reversion) or, on a fresh thrust through an extreme, the start of a new trend (momentum). It's unbounded, so the extremes are relative to each asset.
How it works¶
For each bar the block takes the typical price ((high + low + close) / 3), subtracts its SMA over Period (default 20), and divides by the mean absolute deviation scaled by a constant (0.015). That scaling is deliberately tuned so that, historically, most readings fall between −100 and +100 — which is why those two values are the conventional extremes.
The block draws Overbought (default +100) and Oversold (default −100) as dashed guides in the sub-pane, and exposes plain OB and OS signals that fire true when CCI pushes beyond them. Unlike a 0–100 oscillator, CCI can and will spike well past ±200 in strong moves — that overshoot is information, not an error.
When to use it¶
Use CCI for stretch detection. In ranges, fade moves back from ±100 toward zero. In trends, flip the interpretation: a push through +100 can signal momentum igniting, and pullbacks toward zero become entry points in the trend's direction. Divergence — price making a new extreme while CCI doesn't — is one of its cleaner reversal warnings. As always, fading extremes inside a strong trend is the way to get hurt.
Example¶
A trend-pullback entry: define bias with a 200-EMA, then wire bars into CCI and look for CCI dipping toward zero and turning back up via a Crosses Above at a level like −100. Combine with the bullish bias through an And gate into a Buy Signal, protect with an ATR-based Fixed Stop-Loss, and backtest in the Tester.
Tips & gotchas¶
- It's unbounded. Don't treat ±100 as a ceiling — readings of ±200/±300 happen in real trends and often mean strength, not an imminent reversal.
- Period sets the rhythm. Shorter (14) = twitchy and signal-rich; longer (20–40) = smoother, fewer false stretches.
- Direction of exit beats the touch. Entering as CCI turns back from an extreme is more reliable than entering the moment it tags ±100.
- Tune thresholds per asset. Volatile markets justify ±150/±200 to avoid constant false triggers.
- Pairs well with a trend filter like ADX / DMI so you know whether to fade the extreme or trade through it.
Related blocks¶
Inputs¶
| Socket | Type | What to wire in |
|---|---|---|
| Bars | bars |
Price bars |
Outputs¶
| Output | Type | Plots as | Description |
|---|---|---|---|
| CCI | series |
Line · sub-pane | CCI value |
| OB | signal |
— | CCI above overbought threshold |
| OS | signal |
— | CCI below oversold threshold |
Parameters¶
| Parameter | Type | Default | What it does |
|---|---|---|---|
| Period | number · 2–200 | 20 |
|
| Overbought | number · 0.0–500.0 | 100.0 |
|
| Oversold | number · -500.0–0.0 | -100.0 |
|
| Line color | colour | #ba68c8 |
Chart guides
This indicator draws reference level(s): overbought, oversold.
Reference auto-generated from the block catalog · category Indicators.