MartingaleEA-5 Levels
This EA implements a 5-level martingale strategy that adds to losing positions at predefined distance intervals with multiplied volume. It opens additional buy/sell positions when price moves against the initial trade by specified pip distances, doubling (or multiplying) the lot size each level. All positions of the same direction are closed when total profit or loss reaches a threshold.
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: High
- Increases the position size after losses (martingale)
- Has no stop loss or trailing stop
- Can hold up to 5 positions at once
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 is based on the classic martingale principle: doubling down after losses in hopes of recovering all losses with one winning trade. Entry conditions: when an existing buy (or sell) position is in loss and price has moved against it by cumulative distance thresholds (e.g., Level 1 at 300 pips, Level 2 at 700 pips, etc.), a new same-direction position is opened with volume multiplied by the MartingaleVolumeMultiplier. Exit conditions: all positions of the same direction are closed when total profit reaches MartingaleTakeProfit ($200) or total loss hits MartingaleStopLoss (-$500), after which counters and volumes reset. Position sizing follows exponential growth — each level multiplies the lot by the configured factor (default 2x), reaching 32x the initial volume by level 5. Money management relies on the total-loss threshold, but this stop-loss can be overwhelmed by slippage and the exponentially growing exposure across levels. A critical flaw exists in the counting logic — BCount and SCount are never reset between ticks properly, and the EA iterates all positions every tick without new-bar checks, risking duplicate entries.
Strengths
- Simple and intuitive code structure that makes the martingale logic easy to understand
- 5-level progressively increasing distance intervals give the market room to retrace before next entry
- Total profit/loss threshold closing mechanism provides a basic risk control framework
Weaknesses
- BCount/SCount are never reset between ticks in OnTick, causing martingale level counting to malfunction after first cycle
- No new-bar detection — iterates all positions every tick, risking duplicate orders or unexpected behavior
- VOL variable is never assigned a value; BMartingaleVol/SMartingaleVol initialize to 0, which may cause zero-volume trades or logic failures
- Martingale strategy inherently carries blow-up risk — at 2x multiplier over 5 levels, final level is 32x initial size with exponential loss potential
- Using Point() for distance calculation doesn't account for symbol digit differences, producing incorrect distances on certain instruments
Possible improvements
- Add new-bar detection (IsNewBar) to prevent trade logic from firing every tick
- Fix VOL initialization — add an input parameter for initial lot size and properly initialize counting variables in OnInit
- Refactor the 5 repeated if-blocks into a loop structure for better maintainability and extensibility
Risk assessment
Overall risk: Dangerous
- Martingale exponential position sizing can blow up the account in extreme market conditions
- Uninitialized VOL variable may cause zero-volume trades or unpredictable behavior
- BCount/SCount not reset in OnTick, making re-entry logic after closing completely broken
- Stop-loss threshold of -$500 is likely insufficient for 5-level 2x martingale — actual max loss can far exceed this
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
MartingaleMode | true | Enable martingale mode |
Symbol_Name | EURUSD | Trading symbol name to monitor |
MartingaleVolumeMultiplier | 2 | martingaleposition additionlot size multiplier |
MargingaleNum | 4 | Maximum martingale add-on count (up to 5) |
MartingaleDis1 | 300 | Level 1 add-on distance (points) |
MartingaleDis2 | 400 | Level 2 add-on distance (points) |
MartingaleDis3 | 500 | Level 3 add-on distance (points) |
MartingaleDis4 | 600 | Level 4 add-on distance (points) |
MartingaleDis5 | 700 | Level 5 add-on distance (points) |
MartingaleTakeProfit | 200 | Take profit amount for all same-direction positions (USD) |
MartingaleStopLoss | -500 | Stop loss amount for all same-direction positions (USD) |
Similar Martingale EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.