Martingale Trade Simulator
A Strategy Tester-only EA that provides a manual trading panel with Buy/Sell buttons and optional Martingale averaging and trailing stop features. When martingale is enabled, it opens additional positions with multiplied lot sizes at fixed pip intervals against the losing direction, then adjusts all positions' TP to the volume-weighted average price plus a profit target. The trailing stop feature moves SL to lock in profits when only one position exists per direction.
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 | — | — | — | — | — | Not convertible yet |
| GBPUSD | 0.00% | 0.00% | 0.00% | 0 | — | — | — | — | — | Not convertible yet |
| USDJPY | 0.00% | 0.00% | 0.00% | 0 | — | — | — | — | — | Not convertible yet |
| XAUUSD | 0.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: 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 EA implements a classic Martingale averaging strategy: after an initial manual entry, if price moves against the position by StepPips, it opens an additional position with lot size multiplied by nextLot, thereby shifting the volume-weighted average price closer to current price so that all positions can profitably close at the average price plus TPPlus. Entry conditions are entirely manual—the user clicks Buy or Sell buttons on the tester panel, with no automated signal generation. Exit conditions include the original SL/TP, the martingale-adjusted unified TP (weighted average price ± TPPlus), and an optional trailing stop that only activates when exactly one position exists per direction. Position sizing uses exponential growth: the Nth additional lot equals the smallest position's lot times nextLot^N, normalized by lotAdjust to conform to broker volume constraints. Money management only checks whether free margin suffices for the next trade via CheckMoneyForTrade, lacking any maximum position count, total volume cap, or drawdown protection—making the exponential lot growth extremely dangerous during sustained adverse moves.
Strengths
- Provides a visual tester panel for convenient manual trade simulation in the Strategy Tester
- The martingale averaging logic accounts for swap and commission corrections in the weighted average price calculation, which is relatively precise
- The trailing stop distinguishes between initial stop-loss movement and profit-locked trailing, with relatively complete logic
- The lotAdjust function correctly normalizes lot sizes to broker step, min, and max constraints
Weaknesses
- The martingale strategy is inherently high-risk; exponential lot growth during consecutive losses can easily blow the account, with no maximum position or lot cap protection
- The trailing stop only activates when exactly one position exists per direction—completely disabled during martingale's multi-position scenarios, creating a logical contradiction
- The modifyAllSLTP function returns after the first successful modification, leaving remaining positions potentially unmodified with incorrect TP/SL
- Magic number is hardcoded to 0, making it impossible to distinguish this EA's positions from other EAs or manual trades, risking unintended operations
- Only runs in Strategy Tester visual mode, cannot be used for live trading or pure optimization runs
Possible improvements
- Add maximum position count and total volume caps to prevent unlimited martingale scaling that leads to account blowup
- Fix modifyAllSLTP to iterate and modify all positions of the same type before returning, instead of returning after the first successful modification
- Use a non-zero magic number to distinguish this EA's positions, and allow operation in non-visual tester modes
- Extend trailing stop to support multi-position scenarios, or at minimum provide an equity-based overall stop mechanism when multiple positions are open
Risk assessment
Overall risk: Dangerous
- Martingale strategy with exponential lot growth and no maximum position/lot cap guarantees account blowup in extreme market conditions
- Trailing stop is completely disabled during multi-position martingale scenarios, leaving no dynamic stop protection after averaging orders are placed
- Magic number of zero risks unintended modifications to positions from other EAs or manual trades
- modifyAllSLTP only modifies the first position then returns, causing inconsistent TP/SL across the position group
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
Lots | 0.01 | Initial lot size |
StopLoss | 500 | Stop loss in points |
TakeProfit | 500 | Take profit in points |
TrailingStop | 50 | Trailing stop in points |
TrailingStep | 20 | Trailing step in points |
nextLot | 1.2 | Martingale lot multiplier |
StepPips | 150 | Position addition distance in points |
TPPlus | 50 | Additional TP points on martingale average price |
Similar Martingale EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.