◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Home / Indicators / Commodity Channel Index (CCI)
Momentum indicator

Commodity Channel Index (CCI)

An oscillator that measures how far price has moved from its recent average, scaled by recent volatility.

Illustrative diagram — not live market data.

What it is

The Commodity Channel Index (CCI) is a momentum oscillator developed by Donald Lambert and introduced in 1980. Despite the name, it is not limited to commodities — traders apply it to stocks, forex, indices, and crypto. CCI compares the current "typical price" to a moving average of that typical price over a chosen period, then scales the result by the average deviation of price over the same period. It oscillates around a zero line and is technically unbounded (no fixed maximum or minimum), though the formula is designed so that most readings fall roughly between -100 and +100. It is an educational tool for studying momentum; like all indicators, it is calculated from past prices and is not predictive of future prices, and all trading carries risk of loss.

How it works

CCI starts from the "typical price" of each bar, which is the average of the high, low, and close ((H+L+C)/3). It then compares that typical price to a simple moving average of the typical price over the lookback period (commonly 20). The difference is divided by the mean absolute deviation of the typical price from that moving average, and the result is multiplied by a constant (0.015) that Lambert chose so that roughly 70-80% of readings land within a -100 to +100 range. In plain terms: a high positive CCI means price is unusually far above its recent average, and a deeply negative CCI means price is unusually far below it. Because the scale adapts to recent volatility, the same numeric reading can describe different conditions in calm versus choppy markets.

How traders read it

Common settings

A 20-period CCI is the most widely used default, with ±100 as the reference bands. Shorter settings such as 14 give faster but noisier readings; longer settings such as 50 produce smoother output. Some traders widen the bands to ±150 or ±200 on more volatile instruments. It is sensible to study settings on the specific market and timeframe rather than assuming any default is optimal.

Strengths

Pitfalls to watch

Pine v6 example

//@version=6
indicator("CCI Example", overlay = false)

length = input.int(20, "Length", minval = 1)
src    = hlc3  // typical price (high + low + close) / 3
cci    = ta.cci(src, length)

plot(cci, "CCI", color = color.blue)
hline(100,  "Upper", color = color.gray, linestyle = hline.style_dashed)
hline(0,    "Zero",  color = color.gray)
hline(-100, "Lower", color = color.gray, linestyle = hline.style_dashed)

Pro tip: Treat the ±100 bands as a starting point, not a rule. Pull up your specific market and timeframe and observe how often CCI actually reaches those levels — a quiet instrument may rarely touch ±100, while a volatile one may exceed it constantly. Calibrating the bands to what the chart actually does can make the readings more informative than relying on the default. Remember this is for studying momentum, not for generating buy or sell decisions.

Built an indicator from this? Run it through the Validator to catch look-ahead bias and repainting, or convert a strategy to Pine Script.

Educational only — not financial advice, not a recommendation to trade. No indicator is predictive; trading involves substantial risk of loss.

Catch the bug that compiles.Run auditGet Pro