MA MACD Position averaging v2
This EA uses a combination of Moving Average and MACD indicators to generate trade signals, then employs a position averaging (martingale-style) strategy by adding to losing positions at predetermined intervals. It opens initial positions based on MA/MACD crossover signals and progressively increases lot size as price moves against the position, aiming to recover losses when the market reverses.
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 | -3.86% | -3.36% | 5.35% | 96 | 47.40% | -0.95 | -0.72 | 7 | −$3.71 | Reliable |
| GBPUSD | +4.91% | +4.25% | 5.01% | 97 | 50.50% | 0.94 | 0.98 | 7 | +$5.06 | Reliable |
| USDJPY | +1.89% | +1.64% | 4.59% | 92 | 47.80% | 0.48 | 0.41 | 5 | +$2.05 | Reliable |
| XAUUSD | +28.20% | +22.78% | 60.37% | 88 | 52.90% | 0.69 | 0.47 | 7 | +$35.26 | Reliable |
Profitable on 3 of 4 markets with reliable results.
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 Martingale EAs with a reliable result on the same market: EURUSD: better than 19% of 16 · GBPUSD: better than 80% of 15 · USDJPY: better than 44% of 16 · XAUUSD: better than 44% of 16
Month by month
| Market | Months with a gain | Best month | Worst month |
|---|---|---|---|
| EURUSD | 23% | +2.07% 2026-04 | -1.69% 2026-08 |
| GBPUSD | 62% | +3.00% 2026-07 | -2.51% 2026-10 |
| USDJPY | 54% | +3.16% 2026-04 | -1.91% 2026-03 |
| XAUUSD | 62% | +41.03% 2026-01 | -27.25% 2026-03 |
From the backtest equity curve, sampled about every two days; only reliable results.
Blow-up risk: Elevated
- Increases the position size after losses (martingale)
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 combines a dual-confirmed trend-following entry using MA and MACD indicators with a martingale-style position averaging approach for position management. Entry conditions require alignment between the MA direction and MACD signal line crossover, providing dual indicator confirmation to reduce false signals. Exit conditions depend on the overall portfolio reaching a profit target or hitting a stop loss, rather than individual trade profit/loss. Position sizing employs an averaging-down model where additional positions are opened at fixed pip intervals with increasing lot sizes (typically doubling or scaling by a coefficient), which is a classic martingale characteristic. Money management attempts to limit extreme risk by setting a maximum number of averaging steps and a total stop loss, but the inherently escalating lot sizes cause risk to grow exponentially during losing streaks. The strategy performs well in ranging markets but can suffer catastrophic losses in strong trending markets where price continuously moves against the accumulated position.
Strengths
- Dual indicator confirmation reduces false signal probability
- Averaging strategy effectively reduces average cost and profits in ranging markets
- Well-parameterized design with adjustable averaging count and step for optimization
- Maximum averaging count limit prevents infinite position accumulation
- Long-period MA filtering effectively reduces counter-trend trades
Weaknesses
- Martingale-style averaging causes exponentially growing risk in trending markets
- Stop loss set to 0 means no protection during extreme market moves
- Escalating lot sizes dramatically increase margin call risk with each averaging step
- Lack of account balance check may attempt averaging even with insufficient margin
- Does not account for spread and commission impact on breakeven threshold
Possible improvements
- Add a mandatory total stop loss or maximum account drawdown limit as a safety net
- Implement available margin check before opening averaging positions to ensure sufficient funds
- Add spread filter and commission calculation to prevent small profits from being consumed by trading costs
Risk assessment
Overall risk: High risk
- Martingale averaging strategy can lead to account blow-up in strong trending markets
- Default stop loss of 0 provides no downside protection
- No margin sufficiency check may attempt averaging with insufficient funds
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
LotSize | 0.01 | Trade lot size per order |
MAPeriod | 200 | Moving average period |
MACDFastEMA | 12 | MACD fast EMA period |
MACDSlowEMA | 26 | MACD slow EMA period |
MACDSignalSMA | 9 | MACD signal SMA period |
AveragingStep | 500 | Distance between additional positions in points |
LotMultiplier | 1.5 | position additionlot size multiplier |
MaxAveragingCount | 5 | Maximum position additions |
TakeProfit | 1000 | Overall take profit target in points |
StopLoss | 0 | stop losspoints (0meansnostop loss) |
MagicNumber | 12345 | EA magic number for trade identification |
Similar Martingale EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.