AI CCI Reversal Trader
- Experts
- Version: 1.0
- Activations: 5
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.
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.
