EA-1085 · Mean Reversion

Divergence Trader

This EA trades based on the divergence between a fast and slow Simple Moving Average. It opens buy positions when divergence is positive within a defined range and sell positions when divergence is negative within a mirrored range. It includes trailing stop, breakeven, basket profit/loss closing, and multi-lot position scaling features.

Open the interactive view (equity curve, symbol switch)

Key facts

RiskMedium
Blow-up riskLow
Rating★★☆☆☆
TypeTrading EA
TimeframesM15, H1, H4, D1
IndicatorsSMA
AuthorInteger

Backtest results (H1, about 1 year)

SymbolP&LAnnualMax DDTradesWin rateSharpeRecoveryLosing streakPer tradeStatus
EURUSD0.00%0.00%0.00%0—————Not convertible yet
GBPUSD0.00%0.00%0.00%0—————Not convertible yet
USDJPY0.00%0.00%0.00%0—————Not convertible yet
XAUUSD0.00%0.00%0.00%0—————Not convertible yet

Why this EA never traded: no entry rule survived the conversion.

Converted from MQL5 to Python and run with the same rules for every EA. Positions use MT5 lot sizes (100,000 units per FX lot, 100 oz per gold lot) with 1:100 leverage, one order at a time, and a stop-out below 10% of the starting balance. Sharpe is computed from the equity curve. Results marked as unreliable are shown for completeness only.

Blow-up risk: No blow-up pattern found

None of the usual blow-up patterns were found in the code, and the account was not stopped out in our backtests. That is not a guarantee: any EA can lose money.

High: stopped out in our backtest, or martingale/grid sizing without a stop loss. Elevated: martingale or grid sizing with a stop loss, or several positions at once without a stop loss. What the label means and what we found →

Strategy analysis

The strategy concept is based on the divergence between two SMAs of different periods (default 7 and 88), calculating the change rate of current divergence versus the previous bar's divergence to detect momentum deceleration, which follows a mean-reversion logic. Entry conditions: buy signals require divergence between DVBuySell (0.0011) and DVStayOut (0.0079), sell signals require divergence between negative DVStayOut and negative DVBuySell, meaning positions are only opened at moderate divergence levels while excessive divergence triggers a stay-out zone. Exit conditions rely on fixed stop loss and take profit (default 550 points each), with optional trailing stop and breakeven functionality, but SignalCloseBuy and SignalCloseSell always return false, lacking active closing signals based on strategy logic. Position sizing uses fixed lots (default 0.1), with MultyOpen allowing additional positions in the same direction capped by MaxVolume (0.5 lots). Money management includes basket profit/loss closing functionality that can close all account positions when a specified profit or loss threshold is reached.

Strengths

  • Well-designed divergence zone with stay-out threshold (DVStayOut) prevents entering during extreme divergence conditions
  • Complete stop loss and take profit validation ensures orders comply with exchange minimum stop level requirements
  • Basket profit/loss protection prevents excessive drawdown and locks in overall account profits during extreme market conditions
  • Clean code structure with clear function separation makes the EA easy to understand and modify
  • Uses MQL5 standard library classes (CTrade, CSymbolInfo, etc.) following modern MQL5 programming conventions

Weaknesses

  • SignalCloseBuy and SignalCloseSell always return false, lacking strategy-based active closing signals and relying entirely on stop loss/take profit for exits
  • Divergence calculation is unintuitive — dv1-dv2 simplifies to maF2[0]-maS2[0] (previous bar's fast-slow MA difference), which may not be the author's intended logic
  • Fixed lot sizing without dynamic adjustment based on account balance or risk percentage lacks proper position management
  • No spread filter means frequent signals in high-spread environments can lead to unnecessary losses
  • SolveBuySL and SolveBuyTP use Sym.Ask() which may be stale if called after Sym.RefreshRates() timing is not synchronized

Possible improvements

  • Implement strategy-based active closing signals, such as closing buy positions when divergence reverses from positive to negative
  • Fix the Divergence() function calculation logic so it truly reflects the rate of divergence change, and add comments explaining the calculation
  • Add dynamic position sizing that automatically calculates lot size based on account balance and risk percentage
  • Add a spread filter to pause opening new positions when the spread is too wide, avoiding slippage losses

Risk assessment

Overall risk: Medium

  • Divergence calculation logic may be incorrect, causing signals to behave differently than intended
  • Lack of active closing signals may lead to significant drawdowns during trend reversals when relying solely on stop loss
  • Fixed lot sizing does not adapt to account changes, preventing dynamic risk-based position adjustment
  • DVBuySell and DVStayOut are absolute values requiring significant recalibration across different instruments and volatility environments

Evaluation scores

Code quality3.0
Strategy logic2.0
Risk management3.0
Robustness3.0
Innovation2.0
Documentation2.0
Overall2.5

Parameters

ParameterDefaultDescription
Lots0.1Fixed trading lot size
MultyOpenfalseAllow same-direction position adding
MaxVolume0.5Maximum position lot size limit
StopLoss550Stop loss in points
TakeProfit550Take profit in points
Trailing0Trailing stop in points, 0 to disable
BreakEven0Break-even trigger in points, 0 to disable
Fast_Period7Fast SMA period
Fast_PricePRICE_OPENFast SMA applied price
Slow_Period88Slow SMA period
Slow_PricePRICE_OPENSlow SMA applied price
DVBuySell0.0011Min divergence threshold to open position
DVStayOut0.0079Max divergence threshold, no entry above
BasketProfitONfalseEnable account profit closing
BasketProfit75Close all positions at this account profit
BasketLossONfalseEnable account loss closing
BasketLoss9999Close all positions at this account loss

Similar Mean Reversion EAs

Backtests are historical simulations and do not guarantee future results. Not financial advice.

Get the weekly Arena report

One email a week: ranking changes, new signals and new research. No spam; unsubscribe any time.