CCI Indicator: The Plain Commodity Channel Index

Written by Dominic Walsh · Published · Last updated

The cci indicator does exactly what its name says and nothing more. It plots a 14-bar Commodity Channel Index in its own pane, drawn on typical price. Three reference lines sit at 100, 0 and minus 100. A single switch adds an alert when the reading crosses one of the outer two.

This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Separate window (levels 100 / 0 / -100)
Plots 1: CCI
Alerts popup
Inputs 4

What the CCI Indicator draws on the chart

CCI is a single dodger blue line in the pane below price.

Reference lines mark 100, 0 and minus 100.

The reading is unbounded, so it can travel well past the outer lines.

Nothing appears on the price chart itself.

  • CCI: line, dodger blue, width 2
CCI indicator on EURUSD H1 with the 100, 0 and minus 100 reference lines
CCI indicator on EURUSD H1 with the 100, 0 and minus 100 reference lines

How the CCI Indicator calculates its values

Reading the built-in index

iCCI supplies the value at `CciPeriod` `14` using `AppliedPrice`. The default there is PRICE_TYPICAL, which averages high, low and close. Using the built-in call means the reading matches every other CCI in the terminal exactly.

What the index measures

CCI compares the current typical price with its own average, then scales that gap by the mean deviation over the same window. The scaling is why the reading is roughly comparable between instruments. Around 70 to 80 percent of readings normally fall between the outer lines.

Where the pane stays blank

The loop stops short of the warmup plus two bars, so the oldest region draws nothing. That keeps a partial average from showing as a real reading.

How to read the signals

A move above 100 means typical price is well above its own recent average.

The zero line is where price sits exactly on that average.

Readings past 200 are unusual and mark a genuinely stretched move.

Switch `AppliedPrice` to PRICE_CLOSE if you want wicks ignored.

Alert channels in this build: popup, one message per closed bar.

`ShowAlerts` ships off, which is unusual for this library. Switch it on and the tool raises a terminal popup when the reading crosses plus or minus 100. `AlertPrefix` sets the text in front of the message. There is no push, email or sound channel here, and the guard allows one message per closed bar.

Every CCI Indicator input

Core settings

Setting What it does Default
CciPeriod CCI period. Bars in the index, default `14`. Raise it toward 20 for a calmer line. 14
AppliedPrice Applied price. Price the index reads, default PRICE_TYPICAL. PRICE_TYPICAL

Alert settings

Setting What it does Default
ShowAlerts Alert on +/-100 crossing. Alerts on a crossing of plus or minus 100, default `false`. off
AlertPrefix Alert text prefix. Text placed at the front of the alert message, default `CCI`. CCI
CCI indicator inputs: CciPeriod, AppliedPrice, ShowAlerts, AlertPrefix
CCI indicator inputs: CciPeriod, AppliedPrice, ShowAlerts, AlertPrefix

Settings that fit your chart

CCI travels well because the mean deviation scaling removes most of the instrument difference. EURUSD H1 is the reference chart, where `CciPeriod` at `14` covers a little over half a day. On M5 the line reaches the outer lines several times a session. On daily charts it does so a handful of times a year.

When the CCI Indicator fails

The reading is unbounded, so an extreme value has no ceiling to bounce off.

In a trend CCI can sit above 100 for many bars without anything reversing.

Mean deviation is not standard deviation, so the outer lines are a convention rather than a statistic.

Copy the compiled CCI Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.

Download the CCI Indicator for MT4 and MT5

The zip holds the compiled CCI Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.

Download this indicator free

Enter your email and the file is yours. You also get the full MT4 and MT5 library.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

Why does AppliedPrice default to PRICE_TYPICAL?

Because that is the original definition. Typical price averages high, low and close, so the reading takes account of the whole bar rather than just where it finished. Switch to PRICE_CLOSE if you prefer the wicks left out of it.

How many bars does CciPeriod average?

Fourteen bars of typical price, both for the average and for the mean deviation that scales the result. On EURUSD H1 that is a little over half a day. Raising it toward 20 calms the line and pushes readings past 100 less often.

Can the CCI plot go past 200?

Yes, and it does. The index has no upper or lower bound. The 100 and minus 100 lines are a convention, chosen because most readings fall inside them. A move past 200 is unusual, which is exactly what makes it worth noticing.

What happens when you set ShowAlerts to true?

Every crossing of plus or minus 100 raises a terminal popup, with `AlertPrefix` in front of the message. It ships off because those crossings are frequent on fast charts, and most traders want to watch the line for a while before being told about it.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the CCI Indicator as one input. Always backtest before trading live.

Category: this is part of our Oscillators collection. Also, truly, browse more Oscillators for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment