An Expert Advisor (EA) is different from every other download on this site — an indicator only plots or alerts, while an EA actually sends orders on your behalf. This free EA trades a single, transparent mean-reversion strategy built on CCI: it watches for CCI to turn back out of the +100/-100 extreme, then opens a trade with an ATR-based Stop Loss, an RR-multiple Take Profit, and a risk-based position size — all calculated automatically, with no manual chart-watching required.
How the Strategy Works
The signal this EA trades is the same one taught in the site's own CCI lesson: CCI measures how far the "typical price" has strayed from its own moving average, with no hard ceiling or floor on the answer, so a value of -150 or -220 is a perfectly normal reading during a sharp move rather than a sign the indicator is broken. The meaningful moment for this EA is not CCI reaching an extreme, but CCI turning back through it. A BUY setup forms when CCI (default 14-period, calculated off the typical price) crosses back above OversoldLevel (default -100) after having been at or below it on the previous bar — not the moment CCI first drops under -100, but the bar where it climbs back above that line. A SELL setup mirrors this: CCI crossing back below OverboughtLevel (default +100) after having been at or above it. Trading the touch itself, rather than the turn back out, is the classic beginner mistake with any extreme-reading oscillator — this EA is built to avoid it mechanically, since it only evaluates the cross-back condition and never fires on the bar that first enters the zone.
Stop Loss, Take Profit, and Position Sizing
Every trade's Stop Loss is sized from ATR rather than a fixed pip distance: SL distance = ATR (14-period, ATRPeriod) × ATRMultiplier (default 2.0). A volatile pair or session gets a wider stop automatically; a quiet one gets a tighter stop — the stop always reflects what the market is actually doing right now, rather than an arbitrary fixed number that's too tight on some pairs and too loose on others. Take Profit is then set at RiskRewardRatio (default 2.0) times that same SL distance, so every trade opened by this EA carries a fixed, known risk-to-reward ratio regardless of which pair or timeframe it's running on.
Position size is calculated the same way it's taught in Risk Management Basics: RiskPercent (default 1.0%) of account balance, divided by the Stop Loss distance and converted through the symbol's tick value, gives a lot size where a losing trade costs roughly the same fraction of the account no matter how wide or narrow that particular ATR-based stop happens to be. The result is normalized to the broker's minimum lot, maximum lot, and lot step before being sent with the order. Traders who'd rather trade a constant lot size regardless of account balance or stop width can flip on UseFixedLot, which overrides the risk-based calculation with a flat FixedLotSize instead.
Entry Conditions
- BUY — CCI crosses from at-or-below the Oversold level back above it (CCI was ≤ -100 on the previous completed bar, and > -100 on the current bar).
- SELL — CCI crosses from at-or-above the Overbought level back below it (CCI was ≥ +100 on the previous completed bar, and < +100 on the current bar).
On top of the signal itself, several safety mechanics keep the EA well-behaved on a live account. It opens one position at a time — before considering a new entry, it counts existing positions filtered by symbol and magic number, and skips the signal entirely if one is already open. Every order it places is tagged with its own magic number (20260723), so it never touches trades opened manually or by a different EA sharing the same chart or account. It evaluates entry logic once per new bar only, tracking the timestamp of the last bar it processed rather than re-checking on every incoming tick, so a single cross-back can't fire the same trade multiple times before the bar closes. And before sending any order, it checks the current spread against MaxSpreadPoints and skips the entry entirely if the market is too illiquid at that moment — the same concern covered in Spread and Slippage.
Parameters
- CCIPeriod (default 14) — the lookback period for the CCI calculation, applied to the typical price (
PRICE_TYPICAL). Shorter reacts faster and crosses the ±100 lines more often; longer is smoother and more selective. - OversoldLevel (default -100.0) — the lower CCI threshold; a BUY fires when CCI crosses back above this level after having been at or below it.
- OverboughtLevel (default 100.0) — the upper CCI threshold; a SELL fires when CCI crosses back below this level after having been at or above it.
- ATRPeriod (default 14) — the lookback period used to calculate ATR for the Stop Loss distance.
- ATRMultiplier (default 2.0) — Stop Loss distance = ATR × this multiplier.
- RiskRewardRatio (default 2.0) — Take Profit distance = Stop Loss distance × this ratio.
- RiskPercent (default 1.0) — percentage of account balance risked per trade, used to calculate lot size against the ATR-based Stop Loss distance. Ignored if
UseFixedLotis enabled. - UseFixedLot (default false) — when enabled, every trade uses
FixedLotSizeinstead of the risk-based calculation. - FixedLotSize (default 0.01) — the flat lot size used only when
UseFixedLotis enabled. - MaxSpreadPoints (default 30) — skips new entries while the spread is wider than this, avoiding entries at a bad price during illiquid conditions.
- EnableTrading — a master on/off switch, useful for pausing the EA without removing it from the chart.
- MagicNumber (default 20260723) — the unique identifier tagged on every order this EA opens, used to isolate its positions from manual trades and other EAs.
Why CCI's Unbounded Scale Changes the Reversal Trade
RSI and Stochastic are both capped at 0-100, which means an "oversold" reading on either one can only ever mean the same thing: the scale has run out of room. CCI has no such ceiling or floor, and that changes what an oversold signal on this EA actually represents. When RSI hits 20, it genuinely cannot go much lower — the math bounds it. When CCI crosses below -100, that's just the conventional line traders watch; the underlying value can keep falling to -150, -250, or further with no mathematical limit at all, because it's measuring distance from the average, not position within a fixed range. A strong, sustained trending move can push the typical price further and further from its own moving average for many bars in a row, which means CCI can sit below -100 — or plunge deeper below it — for a long stretch without ever "running out of room" to signal a reversal.
That has a direct, practical consequence for this specific EA: because a cross back above -100 is defined purely by relative movement (this bar's CCI is higher than -100, last bar's wasn't), a brief pause or minor bounce inside a still-intact downtrend can trigger a BUY even though the larger trend has not actually turned. RSI-based mean reversion has some natural insurance against this because the scale itself compresses near the extremes; CCI's unbounded design gives it no such insurance. This is the mechanical reason a CCI reversal EA benefits more than most from being paired with a trend-strength filter — reading ADX or checking trend vs range conditions before enabling it — since the indicator on its own cannot distinguish "the extreme move is genuinely exhausted" from "the extreme move paused for a few bars on its way to a more extreme reading."
Installation and Setup
EAs install into a different folder than indicators — this is the step people miss most often.
- Download the file below for your platform.
- Open MetaTrader → click
File→Open Data Folder. - Place the file in
MQL4/Experts(MetaTrader 4) orMQL5/Experts(MetaTrader 5) — not the Indicators folder. - Restart MetaTrader, then drag the EA from the Navigator window onto a chart.
- Enable AutoTrading (MT4) or Algo Trading (MT5) in the toolbar — the EA will not place any trades while this is off, even if it's attached to a chart.
- Review and adjust the input parameters in the EA's settings dialog before confirming.
A Word of Caution
Test on a demo account first, across different market conditions, before risking real money — past performance, in backtests or live, never guarantees future results. No strategy, automated or manual, wins every trade, and this EA can and will lose money on individual trades. Mean-reversion systems in general get hurt in strong trending markets, and this EA has a specific version of that risk explained above: because CCI has no floor, a strongly trending market can keep printing lower lows through -100 again and again, triggering BUY signals that look like a bottom but are really just a pause inside a continuing decline — a classic "catch a falling knife" scenario. Consider pairing it with a trend-strength filter of your own before enabling it on a live account. Both files are source code — open and review them fully, and understand what every parameter does, before using it. This content is general education, not personalized investment advice.
Download the EA
How to Install — MetaTrader 4
- Download the
cci-reversal-ea.mq4file below. - Open MetaTrader 4 → click
File→Open Data Folder. - Place the file in the
MQL4/Expertsfolder. - Restart MetaTrader 4, then drag the EA from the Navigator window onto the chart.
How to Install — MetaTrader 5
- Download the
cci-reversal-ea.mq5file below. - Open MetaTrader 5 → click
File→Open Data Folder. - Place the file in the
MQL5/Expertsfolder. - Restart MetaTrader 5, then drag the EA from the Navigator window onto the chart.
Both files are source code — open and review the full code before using it, for your own safety.