CCI (Commodity Channel Index)
CCI shows how far price has moved from its statistical average and is used to spot extremes and the start of new trends.
What it is
Donald Lambert introduced the Commodity Channel Index in 1980 for commodity markets, but it is now used everywhere. Unlike RSI, CCI has no fixed range and can go very high or low.
How it's calculated
- Typical price = (high + low + close) ÷ 3
- CCI = (typical price − its moving average) ÷ (0.015 × mean absolute deviation)
How traders read it
- Above +100 price is unusually far above its average, below −100 unusually far below.
- Some traders read a move above +100 as the start of an uptrend, others as overbought; choose your approach with a backtest.
- Divergence between CCI and price is useful, as with other oscillators.
Settings
The default length is 20. The 0.015 constant was chosen so most values fall between −100 and +100.
Where it misleads
- With no fixed range, "extreme" in CCI is relative, and it stays very high in strong trends.
- Its opposite readings (trend start or reversal) show that without a clear rule you can read anything into it.
Its Pine Script on Vlevel
This is the script the chart runs. In the chart's indicators window you can open it, change it and save your own copy.
Commodity Channel Index · Pine Script v6
//@version=6
indicator("Commodity Channel Index", shorttitle = "CCI")
length = input.int(20, "Length", minval = 1)
src = input.source(hlc3, "Source")
ma = ta.sma(src, length)
cci = (src - ma) / (0.015 * ta.dev(src, length))
plot(cci, "CCI", color = #2ee6a6)
hline(100, "Upper Band", color = color.new(color.white, 75), linestyle = hline.style_dashed)
hline(0, "Middle Band", color = color.new(color.white, 75), linestyle = hline.style_dotted)
hline(-100, "Lower Band", color = color.new(color.white, 75), linestyle = hline.style_dashed)Indicators describe past prices; none predicts the future. For education, not investment advice.