AI Regime Switch Trader
- Experts
- Versão: 1.0
- Ativações: 5
AI Regime Switch Trader is an Expert Advisor built around a simple but powerful idea: no single trading style works in every market condition. Instead of using one fixed entry method, this EA continuously classifies the current market regime and automatically switches between two independent, purpose-built strategies - a lightweight, fully transparent form of AI-style adaptive decision making, with no external services, DLLs, or network access required.
HOW IT WORKS
Step 1 - Detect the market regime. On every new bar, the EA reads the ADX indicator. When ADX is above the configurable threshold, the market is classified as TRENDING. When ADX is at or below the threshold, the market is classified as RANGING.
Step 2a - Trending logic. In a trending regime, the EA looks for a crossover between a fast and a slow EMA and trades in the direction of the new trend.
Step 2b - Ranging logic. In a ranging regime, the EA looks for RSI extremes (oversold/overbought) confirmed by a touch of the outer Bollinger Band, and trades the bounce back toward the middle of the range.
Step 3 - Risk management. Every position is opened with an ATR-based Stop Loss and Take Profit, so risk automatically adapts to current volatility. An optional ATR-based trailing stop can lock in profit as a trade develops.
KEY FEATURES
- Two complete trading logics in one EA - trend-following and mean-reversion - activated automatically based on the detected regime.
- Regime classification based on ADX, a well-established measure of trend strength.
- Volatility-adaptive Stop Loss, Take Profit and trailing stop based on ATR.
- Built-in spread filter and position-count limit to avoid trading in poor conditions.
- Pre-trade order validation (OrderCheck) before every market order and every SL/TP modification, to reduce broker rejection errors.
- Clean, well-commented MQL5 code with no external dependencies, no DLL calls and no hidden network access.
- Compatible with any symbol and account type; works on netting and hedging accounts.
MAIN INPUT PARAMETERS
- General Settings - Magic Number, working Timeframe, Maximum Spread (points).
- Regime Classifier (ADX) - ADX Period, ADX Trend Threshold.
- Trend Regime Settings - Fast EMA Period, Slow EMA Period.
- Range Regime Settings - RSI Period, RSI Oversold/Overbought levels, Bollinger Bands Period and Deviation.
- Risk Management (ATR) - ATR Period, Stop Loss (ATR multiple), Take Profit (ATR multiple).
- Trade Settings - Lot Size.
- Trailing Stop - Enable/disable, Trail Start (ATR multiple), Trail Step (ATR multiple).
RECOMMENDATIONS
- Default timeframe: H1. The EA can be tested on other timeframes; re-optimize the ADX threshold and EMA/RSI/Bollinger periods for your chosen timeframe and symbol.
- Works on any symbol with a stable spread; always check your broker's typical spread against the Maximum Spread setting.
- As with any automated trading strategy, test thoroughly on a demo account before moving to a live account, and use position sizing that matches your own risk tolerance.
This EA does not guarantee profit. Past behavior of any strategy, automated or manual, is not a guarantee of future results. Always understand the logic of an Expert Advisor and test it yourself before trading it with real funds.
