Multi Divergence EA
This EA detects divergence patterns across three momentum indicators (RSI, MACD, Stochastic) and enters trades when a configurable minimum number of confirmations align. It applies trend and volume filters before opening positions, and uses fixed lot sizing or risk-based money management with configurable stop loss and take profit.
Open the interactive view (equity curve, symbol switch)Key facts
Backtest results (H1, about 1 year)
| Symbol | P&L | Annual | Max DD | Trades | Win rate | Sharpe | Recovery | Losing streak | Per trade | Status |
|---|---|---|---|---|---|---|---|---|---|---|
| EURUSD | 0.00% | 0.00% | 0.00% | 0 | — | — | — | — | — | No trades |
| GBPUSD | 0.00% | 0.00% | 0.00% | 0 | — | — | — | — | — | No trades |
| USDJPY | 0.00% | 0.00% | 0.00% | 0 | — | — | — | — | — | No trades |
| XAUUSD | -92.78% | -88.60% | 95.04% | 75 | 50.70% | -0.49 | -0.98 | 4 | −$123.70 | Account stopped out |
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.
Against the other Momentum EAs with a reliable result on the same market: XAUUSD: better than 27% of 75
Month by month
| Market | Months with a gain | Best month | Worst month |
|---|---|---|---|
| XAUUSD | 31% | +11.15% 2026-04 | -80.01% 2026-05 |
From the backtest equity curve, sampled about every two days; only reliable results.
Blow-up risk: High
- Hit a stop-out in our backtest (equity below 10%) on XAUUSD
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 core is a multi-indicator divergence detection system for momentum reversal trading. Entry conditions require divergence between price and indicator (e.g., price making lower low while indicator makes higher low signals bullish divergence), with at least MinConfirmations indicators confirming the signal, plus optional trend filter requiring price to be on the correct side of EMA50, and optional volume filter requiring recent volume to exceed 1.2x the average. Exit conditions rely on fixed point-based stop loss and take profit, with no trailing stop or dynamic exit mechanism. Position sizing supports both fixed lot size and risk-based calculation using account balance percentage, where the latter dynamically computes lot size based on stop loss points and tick value with normalization. The money management module respects minimum/maximum lot and step constraints but lacks margin verification. Overall strategy logic is clear, but divergence detection only compares the two most recent extrema, potentially missing more complex divergence patterns.
Strengths
- Multi-indicator divergence confirmation mechanism improves signal reliability and reduces false signal risk
- Multiple entry filters including spread filter, trend filter, and volume filter enhance trade quality
- Money management module respects instrument specifications such as min/max lot and lot step constraints
- Clean code structure with well-separated functional modules makes it easy to understand and maintain
Weaknesses
- Ask and Bid variables are incorrectly assigned SYMBOL_ASK and SYMBOL_BID constants instead of real-time prices, causing critical errors in spread calculation and order pricing
- Divergence detection only compares the two most recent extrema, cannot detect complex multi-point divergence patterns, and unsorted extrema arrays may compare mismatched pairs
- CalculateDivergenceStrength formula has logic flaws: simply adding price and indicator changes doesn't properly measure divergence strength, and using MathAbs in denominator may cause division by zero
- Lacks margin check, order fill type setting, and slippage control, which may cause real trading failures due to insufficient margin or excessive slippage
- Trend filter logic contradicts divergence nature: bullish divergence requires price above EMA, but as a reversal signal, price is typically below EMA at that point
Possible improvements
- Fix Ask/Bid variables: should use SymbolInfoDouble to get real-time bid/ask prices instead of assigning constants to double variables
- Improve divergence strength calculation: use normalized directional divergence between price and indicator changes instead of simple addition
- Add multi-point divergence detection and time-sorted extrema pairing to improve accuracy and capture complex patterns
- Add margin check (OrderCalcCheck), configurable order fill type, and slippage tolerance parameters
- Reconsider trend filter logic: for divergence reversal strategies, entry should be allowed when price is on the opposite side of EMA
Risk assessment
Overall risk: Medium
- Ask/Bid variable assignment bug is critical, causing all trades to execute at wrong prices and spread calculation to completely fail
- CalculateDivergenceStrength may cause division by zero errors leading to EA crash or invalid signals
- Lack of margin check may attempt orders when account has insufficient funds, causing errors
- Trend filter logic contradicts divergence reversal strategy, potentially filtering out valid signals
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
LotSize | 0.1 | Fixed lot size |
StopLoss | 100 | Stop loss in pips per order |
TakeProfit | 200 | Overall grid profit target in currency |
MaxSpread | 30 | Maximum allowed spread |
UseMoneyManagement | false | Enable money management |
RiskPercent | 2.0 | Risk per trade as % of account equity |
RSI_Period | 14 | RSI period |
MACD_Fast | 12 | MACD fast EMA period |
MACD_Slow | 26 | MACD slow EMA period |
MACD_Signal | 9 | MACD signal line period |
Stoch_K | 5 | Stochastic %K period |
Stoch_D | 3 | Stochastic %D period |
Stoch_Slowing | 3 | Stochastic smoothing period |
BarsToCheck | 50 | Bar range for divergence detection |
MinBarsDistance | 5 | Minimum bar distance between extremum points |
MinDivergenceStrength | 0.7 | Minimum divergence strength threshold (0-1) |
MinConfirmations | 3 | Minimum indicator confirmations required (1-3) |
UseVolumeFilter | true | Enable volume confirmation filter |
UseTrendFilter | true | Enable trenddirectionfilter |
AllowBuy | true | Allow buytrading |
AllowSell | true | Allow selltrading |
MaxTrades | 1 | Maximum simultaneous positions |
MagicNumber | 123456 | Order magic number to identify this EA's orders |
Similar Momentum EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.