AI CCI Reversal Trader
- Experts
-
Fadi Hassan Khaled Ghanem
MQL4/MQL5 developer based in Jordan. I have published 169 MetaTrader 5 products on the MQL5 Market (about 8,800 downloads in total).
What I build:
- Custom Expert Advisors from your own trading rules
- Indicators, alerts and multi-timeframe dashboards - Version: 2.0
- Updated: 21 September 2026
AI CCI Reversal Trader is an Expert Advisor built around a simple, transparent idea: markets that are not trending tend to snap back after moving too far, too fast. Instead of chasing momentum, this EA waits for the CCI (Commodity Channel Index) to reach an extreme reading, confirms the market is actually ranging (not strongly trending) using ADX, and only then looks for a reversal entry.
Risk & Requirements at a Glance
- One position per symbol and magic number at a time - no stacking of extra trades on the same signal.
- Every trade is opened with an ATR-based stop loss and take profit, with a minimum stop-distance floor; an optional ATR trailing stop follows the trade.
- Fixed base lot (InpLotSize), normalized to your broker's volume rules, plus a margin check with a 20% safety buffer before every trade.
- Mean-reversion logic: best suited to ranging conditions. The ADX filter reduces, but does not eliminate, losses during strong trends.
- New entries are blocked when the spread is above InpMaxSpreadPoints and near session open/close.
- Default settings are a starting point, not tuned for your broker or symbol. Test at least 12 months in the Strategy Tester on your broker's data and run on a demo first. Results are not guaranteed.
How It Works
- CCI extremity: the EA watches the CCI oscillator on your selected timeframe. When CCI drops below -100 (oversold) it looks for a long; when it rises above +100 (overbought) it looks for a short.
- ADX ranging filter: a reversal signal is only acted on when ADX is below a configurable ceiling, confirming the market is not in a strong trend that could keep pushing against the reversal.
- Optional EMA context filter: a 200-period EMA filter can be enabled to avoid taking counter-trend trades too far against the dominant direction.
- Confidence scoring: each potential signal is scored from the CCI's distance beyond the threshold and how comfortably ADX sits below its ceiling. Trades are only opened when confidence clears a configurable minimum.
- ATR-based risk: stop-loss and take-profit are both derived from the Average True Range, so they automatically adapt to current volatility instead of using a fixed pip value.
Risk Management
- Stop-loss and take-profit are calculated from ATR, with a minimum stop-distance floor.
- Position size is normalized to the broker's volume step, minimum and maximum automatically.
- A margin check (with a 20% safety buffer) runs before every trade to avoid over-leveraging the account.
- An ATR-based trailing stop protects profits once a trade is open, and it also respects the broker's minimum stop and freeze levels.
- The EA checks that the trading session is open (with an edge buffer near session open/close) before opening new trades or modifying stops, avoiding failed operations around market close.
- A spread filter blocks new entries when the current spread is wider than the configured maximum.
- Only one position per symbol/magic number is held at a time.
Input Parameters
- InpMagicNumber - unique identifier for this EA's trades.
- InpTimeframe - timeframe used for all indicator calculations.
- InpMaxSpreadPoints - maximum allowed spread (in points) to open a trade.
- InpEdgeBufferSeconds - buffer near session open/close during which no trading occurs.
- InpCciPeriod - period of the CCI indicator.
- InpCciThreshold - CCI level that must be exceeded (positive or negative) to arm a reversal signal.
- InpCciExtremeRange - range beyond the threshold used to scale the confidence score.
- InpAdxPeriod - period of the ADX indicator.
- InpMaxAdxForReversal - maximum ADX value at which a mean-reversion trade is still allowed.
- InpMinConfidence - minimum confidence score (0-100) required to open a trade.
- InpUseEmaFilter - enable/disable the 200-period EMA context filter.
- InpEmaTrendPeriod - period of the EMA filter.
- InpLotSize - base lot size (automatically normalized to the broker's volume rules).
- InpAtrPeriod - period of the ATR indicator used for stops and trailing.
- InpSlAtrMult / InpTpAtrMult - ATR multipliers for stop-loss and take-profit distance.
- InpMinStopPoints - minimum stop-loss distance in points.
- InpUseTrailing - enable/disable the trailing stop.
- InpTrailAtrMult - ATR multiplier for the trailing distance.
- InpTrailStepPoints - minimum step (in points) before the trailing stop is moved again.
Important Notes
- This EA trades a mean-reversion strategy and is best suited to ranging market conditions; the ADX filter is designed to reduce (not eliminate) exposure during strong trends.
- Past performance of any strategy, backtested or live, does not guarantee future results. Always test on a demo account first and use appropriate risk settings for your account size.
- Recommended to run on a VPS for uninterrupted operation.
How to Test It Before Going Live
- Start in the Strategy Tester: pick a liquid pair you normally trade, use "Every tick based on real ticks" if your broker provides it, and test at least 12 months so the EA meets both ranging and trending periods.
- Check the ranging filter first: if you see losing trades clustered during strong trends, lower InpMaxAdxForReversal (fewer but cleaner signals) or enable InpUseEmaFilter.
- Tune frequency with confidence: raising InpMinConfidence or InpCciThreshold means fewer, more extreme setups; lowering them means more trades with weaker reversals. Change one input at a time and compare.
- Then run on a demo account for a few weeks with your real broker's spreads before using real money. Keep InpLotSize small until you understand how the EA behaves on your symbol.
Frequently Asked Questions
- Does it use grid, martingale or averaging? No. It holds one position per symbol and magic number, uses a fixed base lot, and every trade has an ATR-based stop loss from the moment it opens.
- Which symbol and timeframe should I use? There is no single "correct" pair. Because it is a mean-reversion EA, it tends to fit symbols that spend a lot of time ranging. Choose a liquid symbol you already trade, select the timeframe with InpTimeframe, and confirm it in the Strategy Tester on your broker's data first.
- Why is it not opening trades? Usually a filter is doing its job: the spread is above InpMaxSpreadPoints, the market is too close to session open/close, ADX is above InpMaxAdxForReversal (trending market), or the signal is below InpMinConfidence. Few trades during strong trends is expected behavior.
- Can I run it on several charts at once? Yes. Give each chart a different InpMagicNumber so the EA manages each set of trades separately.
- Is it suitable for prop-firm accounts? It uses a stop loss on every trade and no grid, which helps, but it has no built-in daily-loss or max-drawdown lock. If your prop firm has those rules, ask me for a custom version with those limits added.
- Is there an MT4 version? This product is for MetaTrader 5. An MT4 version can be built on request (see below).
Need a Custom Version?
I can adapt this EA to your own rules - extra filters, a session/time filter, different money management (risk % per trade), prop-firm daily-loss and drawdown limits, or an MT4 version. Send me a private message here on MQL5 (or offer me a personal order via MQL5 Freelance) with your requirements, and I'll reply within 24 hours with whether it's doable and the estimated scope.
If you find this free version useful, please leave a review - it helps a lot and tells me which features to improve next.
More free tools from the same developer
- AI Breakout Range Box Indicator - draws a price range box on the chart and highlights breakouts (indicator, pairs well with this EA for manual confirmation).
- AI Volume Divergence Trader - another reversal-style EA, based on price/volume divergence instead of CCI.
- Ichimoku Trend Rider - a trend-following EA, if you prefer trading with the trend instead of reversals.
