VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Indicators and signals

CCI indicator: formula, ±100 levels and how to backtest it on futures

The CCI measures how far the typical price sits from its moving average, scaled by 0.015 so that most readings fall inside ±100. The same ±100 crossing can be traded as a reversal or as a breakout; the two rules point in opposite directions and must be tested as separate candidates, with costs set before the first run.

By · Published · updated · Editorial policy

Contents
  1. How is the CCI indicator calculated?
  2. What CCI level counts as overbought or oversold?
  3. Reversal or breakout: which way should you trade the ±100 line?
  4. CCI settings: 14 or 20 periods?
  5. How does CCI differ from RSI and KD?
  6. How do CCI rules behave on different futures markets, and how do you read a backtest?
  7. Frequently asked questions
  8. References

How is the CCI indicator calculated?

The CCI indicator (Commodity Channel Index) measures how far the typical price of a bar sits from its own moving average, in units of the average distance over the lookback. A constant of 0.015 scales the result so that, by design, most readings fall between −100 and +100, and the readings beyond those lines are the zones that CCI rules trade.

Four quantities build the reading. Typical price is the average of a bar's high, low and close. The average is a simple moving average of the typical price over N bars, where N is the period you set (14 and 20 are the common choices). Mean deviation is the average of the absolute distances between each of the last N typical prices and that moving average, so it describes how far the typical price normally wanders. The CCI indicator page holds the full definition; the one formula worth remembering is:

CCI = (typical price − average) ÷ (0.015 × mean deviation)

Here typical price − average is today's distance from the average, mean deviation is the normal distance, and 0.015 is a fixed scaling constant. Dividing by the normal distance turns the reading into "how many normal distances away are we", and the constant stretches that number so that ordinary bars land inside ±100. The constant is not a setting to tune; the period is. Where CCI sits among the other oscillators and channel tools, and which of them can be written as fixed rules, is covered in the guide to technical analysis tools and indicators you can test.

Hypothetical example

Suppose today's typical price is 101, the 20-bar average of typical price is 100, and the mean deviation over those 20 bars is 0.5. The distance from the average is 1. The CCI is 1 ÷ (0.015 × 0.5) = 1 ÷ 0.0075 ≈ 133. The price is two normal distances above its average, and the reading sits above +100. If the mean deviation had been 1.0 instead, the same price would read about 67, inside the normal zone.

How the CCI is calculated in four steps: typical price, its simple average over N bars, the mean deviation from that average, and the CCI as the distance from the average divided by 0.015 times the mean deviation, where 0.015 only sets the scale so most readings fall inside plus or minus 100 Price to CCI in four steps 0.015 puts most readings inside ±100 1 2 3 4 Typical price Average Mean deviation CCI TP = (H + L + C) ÷ 3 avg = TP over N bars MD = mean |TP − avg| (TP − avg) ÷ (0.015 × MD) 0.015 only fixes the scale. So: tune the period, never 0.015.
From price to CCI in four steps. The 0.015 constant enters only at the last step and only to set the scale.

What CCI level counts as overbought or oversold?

By convention a reading above +100 is overbought and a reading below −100 is oversold, with ±200 marking an extreme, but these are zones the line visits often, not rare signals. The scaling is built so that most readings fall inside ±100, which means a meaningful minority fall outside. A strong trend can hold the reading above +100 for many bars in a row, and the price keeps rising while the indicator says "overbought" the whole time.

Three zones are enough for rule writing. Inside ±100 is the normal zone, where the price is near its average. Between ±100 and ±200 is the overbought or oversold zone, where the price is stretched. Beyond ±200 is the extreme zone, which the line reaches less often and usually during a fast move or a volatility shock. How much time the line spends in each zone depends on the market, the bar size and the period, so the useful habit is to count it on your own data: load your bars, pick your period, and count the share of bars outside ±100. That share tells you how often a reversal rule would be armed and how often a breakout rule would fire.

An illustrative CCI line over 60 bars with the normal zone between minus 100 and plus 100, overbought and oversold zones beyond plus and minus 100, and extreme zones beyond plus and minus 200; the line leaves the normal zone several times, and those stretches are highlighted The line leaves ±100 often CCI on 60 illustrative bars +200 +100 −100 −200 Extreme Overbought Normal Oversold Extreme Outside ±100 is common, not rare. So: count it on your own bars.
The three CCI zones. The line leaves the normal zone regularly, so ±100 is a condition to build a rule on, not a signal by itself.

Two readings of the same level follow from this. A mean-reversion trader reads +100 as "stretched, likely to come back". A trend trader reads +100 as "strong enough to follow". Neither reading is wrong on its own; the next section shows that they produce opposite trades.

Reversal or breakout: which way should you trade the ±100 line?

The same ±100 crossing can be written as a reversal rule or as a breakout rule, the two rules trade in opposite directions at the same bar, and they must be tested as separate candidates. A reversal rule is a mean-reversion rule that waits for the line to come back out of the overbought or oversold zone and trades against the move. A breakout rule is a trend rule that enters when the line pushes into the zone and trades with the move.

Rule partBreakout (trend) ruleReversal (mean-reversion) rule
Long entryCCI crosses above +100CCI crosses back above −100 after being below it
Short entryCCI crosses below −100CCI crosses back below +100 after being above it
Common exitCCI crosses the zero line against the positionCCI reaches the zero line, or a fixed number of bars
Holding timeLonger; rides the trendShorter; takes the snap back
Market it suitsTrending stretchesRange-bound stretches
Typical failureWhipsaws when the line hovers around ±100Fighting a trend that holds beyond ±100
The same CCI line under two rules: the breakout rule goes long when the line crosses above plus 100 and exits when it crosses below zero, while the reversal rule goes short when the line crosses back below plus 100 and exits at zero, so at that bar one rule is long and the other is short Same cross, opposite trades One CCI line under two rules Breakout rule Reversal rule +100 0 Long Short Exit Exit Same bar: long here, short there. So: test them as two candidates.
One CCI line, two rules. At the bar where the breakout rule is still long, the reversal rule goes short.

Write each rule down with every condition fixed before you test it: which crossing enters, which crossing or level exits, and whether the rule trades both sides. "Trade the ±100 line" is not a rule; "go long on the close that crosses above +100, exit on the close that crosses below 0" is. Mixing the two directions in one candidate, for example entering on a breakout and adding a reversal filter later because the equity curve looked soft, turns a test into a fitting exercise.

The breakout version belongs to the same family as the Supertrend flip rule, which also enters after a move has already shown strength. The two differ in what they measure. Supertrend flips when the close crosses a band placed a multiple of the average true range away from price, so it reacts to price passing a volatility-sized distance. The CCI breakout fires when the distance from the average exceeds a multiple of the normal distance, so it reacts to the stretch itself. Supertrend is usually always in the market because each flip reverses the position; the CCI breakout has a separate exit and spends time flat. Testing both on the same bars tells you whether your market rewards "follow after a volatility-sized move" or "follow after a stretch from the average".

CCI settings: 14 or 20 periods?

Neither 14 nor 20 is the right CCI setting in itself; the right period is the one whose neighbouring values behave alike after costs. A shorter period makes the moving average and the mean deviation react faster, so the line crosses ±100 more often and earlier, which gives more trades and more noise. A longer period smooths both, so the line crosses less often and later, which gives fewer trades, later entries and fewer whipsaws.

EffectCCI(14)CCI(20)
Crossings of ±100MoreFewer
Timing of the same crossingEarlierA few bars later
Trades per yearHigherLower
Cost dragHigher, because more trades pay commission and slippageLower
Whipsaws around ±100MoreFewer
Missed start of a moveSmallerLarger
Two illustrative CCI lines on the same price stretch: the 14-period line moves past plus or minus 100 five times and the 20-period line three times, and the 20-period line crosses a few bars after the 14-period line on the same move Short periods cross more Dots mark each move past ±100 +100 −100 CCI(14) 5 crosses CCI(20) 3 crosses 14 crosses more often and sooner. So: test a range of periods.
The same price stretch under two periods. The shorter period crosses more often and sooner; the longer one crosses less often and later.

The way to choose is to test a range, not a pair. Run the rule with periods from about 10 to 30 in steps of 2, with the same commission, slippage and next-bar execution in every run, and put the average trade after costs on one line against the period. A good result is a plateau: a stretch of neighbouring periods, say 16 to 24, that all give a similar average trade. A bad result is a spike: 18 looks good, 16 and 20 look poor. Pardo (2008) describes this plateau test as the basic check of an optimized parameter, and the reasoning is simple. Live prices will not match your history, so a setting that only works at one exact value was describing noise in that history. Pick a period from the middle of the plateau, and record the plateau's width as part of the candidate's description.

The period also sets the trade count, and the trade count decides whether the result means anything. A 20-period reversal rule on daily bars may produce a handful of trades a year; the same rule on 15-minute bars produces many hundreds. Judge the sample in completed trades, not years, before you compare 14 with 20.

How does CCI differ from RSI and KD?

RSI and KD are bounded between 0 and 100, while CCI has no ceiling, so CCI keeps rising in a strong trend where RSI and KD flatten near their upper limit. The three also measure different things. RSI compares average gains with average losses over the period, as described by Wilder (1978). KD, the stochastic oscillator, places the close inside the high-to-low range of the period. CCI measures distance from an average in units of the normal distance. Because RSI and KD are ratios that cannot exceed 100, a trend that keeps making gains pushes them toward the ceiling, where they stop telling you how strong the move is. CCI has no ceiling, so a stronger stretch simply reads higher.

PropertyCCIRSIKD (Stochastic)
ScaleUnbounded0 to 1000 to 100
InputDistance of typical price from its averageAverage gain versus average lossClose within the period's high-low range
Typical levels±100, extremes ±20070 and 3080 and 20
Behaviour in a strong trendKeeps risingFlattens near the ceilingFlattens near the ceiling
Natural rule typeReversal or breakoutMostly reversalMostly reversal, often with %K/%D crosses
Three oscillators during one steady illustrative uptrend: RSI and KD rise and then flatten just under their ceiling of 100, while CCI keeps rising because it has no ceiling CCI has no ceiling Three oscillators, one steady uptrend RSI KD CCI Stops at 100 Stops at 100 Keeps rising RSI and KD flatten; CCI keeps going. So: CCI can follow trends too.
Three oscillators on one trend. RSI and KD run out of room near 100; CCI keeps reading higher as the stretch grows.

This difference changes what each indicator is good for. The ceiling makes RSI's 70/30 levels and the KD indicator's 80/20 levels natural reversal triggers, because a reading near the ceiling cannot go much further. The missing ceiling makes CCI usable as a trend measure too: a reading that climbs from +100 to +250 is new information, while RSI moving from 80 to 85 is barely a change. If you already trade an RSI reversal rule, the CCI reversal rule is a close cousin and will often fire on the same bars; the CCI breakout rule is the one that adds something RSI cannot express.

How do CCI rules behave on different futures markets, and how do you read a backtest?

A CCI rule's result depends more on the market's character than on the indicator, so test each market on its own and read the report by average trade after costs, trade count and drawdown rather than by net profit. Index futures such as ES and TAIEX futures spend long stretches trending, and those stretches reward the breakout use of ±100 while punishing a reversal rule that keeps selling into a rally. Range-bound stretches, which every market has, reward the reversal use and whipsaw the breakout rule. The share of each kind of stretch differs by market and by year, which is why one combined test over several markets hides what is happening in each.

  1. Write the entry and exit as fixed conditions. Which crossing enters, which crossing exits, long only or both sides.
  2. Set commission, slippage and next-bar execution before the first run. A rule that decides on the close must fill on the next bar; filling on the deciding close uses a price you could not have traded.
  3. Run the reversal and breakout versions as separate candidates, over a range of periods, on each market separately.
  4. Read average trade after costs, trade count and maximum drawdown. Net profit alone says nothing about how it was earned.
  5. Check neighbouring periods and the out-of-sample stretch before keeping any candidate.
The order of a CCI test in five steps: fix the entry and exit rules, set costs and next-bar fills, test each rule separately, read average trade, trade count and drawdown, then check nearby periods and the out-of-sample stretch before keeping a candidate The order of a CCI test Each step before the next 1 2 3 4 5 Fix the entry and exit rules Set costs and next-bar fills Test each rule separately Read avg trade, count, drawdown Check nearby periods and OOS Costs are set before any result. So: decide only after the checks.
The order of a CCI test. Costs and execution are fixed before the first run, and the robustness checks come before the decision.

The run below shows what such a report looks like in practice. It tested a Volume Profile Levels rule, a stand-in built from standard indicators rather than a CCI rule, on ES daily bars from 2019-01-02 to 2025-06-30, long and short, one contract, with $20 commission and $25 slippage charged on every trade. It is the one candidate the search kept out of the 1,024 it tried, chosen for its return against its drawdown, and picking the best candidate after the fact flatters it: the kept one carries a selection bonus that a fresh stretch of data will not pay, a point Bailey et al. (2014) make in detail.

Source: AlphaPrime product engine (CPU), run 2026-10-31. ES daily bars, 2019-01-02 to 2025-06-30, long and short, 1 contract, $20 commission and $25 slippage per trade.

NumberResult
Net profit (closed trades)$137,912.5
Max drawdown$37,892.5
Trades160
Win rate51.25%
Profit factor1.482
Average trade$861.95
Time in market84.23%
Read the curve from left to right: where the drawdown was deepest, how long it lasted, and whether the slope after the out-of-sample marker resembles the slope before it.
Read the curve from left to right: where the drawdown was deepest, how long it lasted, and whether the slope after the out-of-sample marker resembles the slope before it. ES · daily · 2019-01-02 to 2025-06-30 · CPU engine backtest

Read it in this order. First the average trade, $861.95, against the $45 of commission and slippage charged on each trade: the costs are a small share of the average trade, so a doubling of slippage would not change the sign. Second the trade count, 160 over about six and a half years, which is enough to make the average meaningful but few enough that a handful of large trades could move it; the trade list tells you how concentrated the result is. Third the maximum drawdown, $37,892.5, against the net profit of $137,912.5: the worst losing stretch took back a little over a quarter of what the whole period earned, and that drawdown, not the net profit, is the number to hold against your account size. Fourth the time in market, 84.23%, which says this rule holds positions most of the time and so carries overnight exposure in almost every week. In AlphaPrime (Valynox) these figures sit together with the trade list and the periodic breakdown in the Performance Report, so the same four numbers can be read for a CCI candidate the moment its run finishes. None of this is a forecast, and a CCI rule tested the same way will show its own numbers.

Hypothetical example

Suppose a CCI(20) breakout rule on an index future shows 400 trades with a gross average trade of $70 before costs. With $45 of commission and slippage per trade, the average trade after costs is $25, a little over half the gross. Doubling the slippage to $50 would bring the cost to $70 and the average trade to zero. The result is positive but thin, so the plateau check and the out-of-sample stretch decide whether to keep it, not the headline profit.

Your next step: take your own bars for one market, write the CCI(20) breakout rule and the CCI(20) reversal rule as two fixed candidates, run each with your real commission, one tick of slippage per side and next-bar execution, and count how many trades each produced. If either has fewer than a few hundred, move to a smaller bar size or a longer history before comparing the two.

Frequently asked questions

Can the CCI go above 200 or below −200?

Yes. The CCI has no upper or lower limit, because it divides the distance from the average by the normal distance and nothing caps the result. Readings beyond ±200 are less common than readings between ±100 and ±200 and usually appear during fast moves or volatility shocks. How often they occur depends on the market, the bar size and the period, so count them on your own data rather than assuming a share.

Is the CCI a leading or a lagging indicator?

It is built from a moving average and a moving mean deviation, so it lags price like any averaged indicator; a shorter period lags less and a longer period lags more. The "leading" impression comes from the reversal use, where a reading leaving the ±100 zone is read as a sign the move is tiring. That is an interpretation of the lagging reading, not a forecast, and it must be tested as a fixed rule like any other.

What time frame works best for CCI?

CCI is calculated the same way on every bar size, so the choice sets the trade count and the holding time rather than the indicator's meaning. Daily bars give a handful of trades a year for a 20-period rule; intraday bars give hundreds. Pick the bar size that gives enough completed trades to judge, run the same rule with the same costs on it, and check that neighbouring periods behave alike before trusting the result.

Does a CCI strategy work on futures?

A CCI rule is a fixed condition on price, so it can be tested on any futures contract with bar data, and whether it holds up is a result to measure, not a property of the indicator. The breakout use tends to suit the trending stretches of index futures and the reversal use tends to suit range-bound stretches, but the mix changes by market and by year. Test each market separately, with commission, slippage and next-bar execution set first, and read the average trade after costs, the trade count and the drawdown.

References

  • Wilder, J. W. (1978). New Concepts in Technical Trading Systems. Trend Research.
  • Pardo, R. (2008). The Evaluation and Optimization of Trading Strategies (2nd ed.). John Wiley & Sons.
  • Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.