CCI
CCI in ProBuilder returns the Commodity Channel Index, an unbounded oscillator measuring price deviation from its mean. Above +100 is overbought territory.
Syntax
CCI[N](price)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
N | integer | 20 | Lookback period for the moving average and the mean deviation. 14 and 20 are the common settings. |
price | price source | typicalprice | Price series used in the calculation. The classic definition uses typicalprice, the average of high, low, and close, but close or any other series is accepted. |
Formula
CCI = (price - MM) / (0.015 * D)Where MM is the N-period simple moving average of the price series and D is the mean absolute deviation of the series from that average over the same window. The 0.015 constant scales the output so that roughly 70 to 80 percent of readings fall between -100 and +100 under typical conditions.
How it works
On every bar, the indicator measures the gap between the current price and its recent average, then asks how large that gap is compared with the typical gap over the window. The result is a normalised distance: a CCI of +200 means price sits about three times further above its mean than usual (after the 0.015 scaling), regardless of the instrument or the price level.
Unlike RSI or Stochastic, CCI has no fixed bounds. Extreme trends can push it to +300, +400, or beyond. This property cuts both ways. It preserves information about just how stretched a move is, but it also means fixed thresholds capture different market states in different volatility regimes.
Two broad usage styles exist. Mean-reversion traders fade excursions beyond +100 or -100, expecting a snap back toward the average. Trend traders read the same levels the opposite way, treating a push through +100 as evidence of an emerging up move. Both styles can be coded from the same function; the surrounding conditions determine which behaviour is captured.
Examples
Example 1, Overbought and oversold signal line (Indicator)
// Signal: +1 above the overbought line, -1 below the oversold line
myCCI = CCI[20](close)
SIGNAL = 0
IF myCCI < -100 THEN
SIGNAL = -1
ENDIF
IF myCCI > 100 THEN
SIGNAL = 1
ENDIF
RETURN SIGNALCompresses the 20-period CCI into a three-state signal: -1 in oversold territory, +1 in overbought territory, 0 in between.
Example 2, Mean-reversion long with a trend filter (ProOrder)
// Buy deep CCI dips in an uptrend, exit when CCI normalises
trend = Average[200](close)
c = CCI[14](typicalprice)
IF NOT LongOnMarket AND close > trend AND c CROSSES OVER -100 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF LongOnMarket AND c CROSSES OVER 100 THEN
SELL AT MARKET
ENDIFWaits for CCI to leave oversold territory rather than entering while it is still falling, and only takes signals above the 200-bar average. The exit banks the trade once CCI reaches the opposite extreme.
Example 3, Screening for extreme readings (ProScreener)
// Instruments stretched more than 200 CCI points from their mean
c = CCI[20](typicalprice)
SCREENER[Abs(c) > 200](c AS "CCI 20")Returns instruments in unusually stretched conditions in either direction, with the signed CCI value shown for sorting.
Interpretation
| Zone | Range | Reading |
|---|---|---|
| Oversold | below -100 | Price is unusually far below its mean. Possible bounce zone, or the start of a strong downtrend. |
| Neutral | -100 to +100 | Price is within its normal band around the average. |
| Overbought | above +100 | Price is unusually far above its mean. Possible pullback zone, or trend ignition. |
The zero line marks price crossing its own moving average and is sometimes used as a bias filter. Divergences between CCI and price at extremes are a common reversal study; the DivergenceCCI instruction detects them directly.
Common errors and gotchas
- Unbounded output breaks RSI-style assumptions. CCI can exceed plus or minus 300 in strong moves. Logic ported from bounded oscillators, such as treating +100 the way RSI treats 70, misjudges how extreme a reading actually is.
- Wrong bracket type.
CCI(20, close)is invalid. The period belongs in square brackets and the price source in parentheses:CCI[20](close). - Price source changes the indicator. The textbook CCI uses the typical price. Passing
closegives systematically different values, especially on bars with long wicks. Backtests and chart studies must use the same source. - Extremes are ambiguous by design. A push above +100 is simultaneously a mean-reversion sell condition and a momentum buy condition depending on the strategy style. The threshold alone carries no edge; the surrounding regime logic decides its meaning.
Related instructions
DivergenceCCI, built-in divergence detection for CCI.RSI, bounded momentum oscillator with fixed 0 to 100 range.Stochastic, bounded oscillator based on range position.SMI, stochastic momentum index.ROC, rate of change, a simple momentum measure.Momentum, raw price difference over a lookback.Williams, Williams %R, another overbought/oversold gauge.TypicalPrice, the default price source of the classic CCI.Average, the moving average at the core of the formula.
