Gold Pullback Martingale
- Experts
- 버전: 1.0
- 활성화: 5
! MARTINGALE RISK WARNING – READ BEFORE USE
This Expert Advisor uses a martingale / averaging strategy: when price moves against an open position it opens additional positions with larger lots in the same direction. This means:
- Many small winning baskets can be wiped out by one losing basket. In our default-settings real-tick backtest, the worst single basket lost -1,142.78 USD on a 10,000 USD account (about 10% of balance), while the average winning basket made only about +13 USD.
- With safety caps disabled, the same logic lost the entire test account (equity drawdown 101%, one basket lost -17,073.87 USD). See screenshot 5.
- Gold (XAUUSD) can move hundreds of points in minutes on news. Gaps and slippage can make losses larger than the configured stops.
- Past backtest results do not predict future results. Only trade money you can afford to lose. Test on a demo account first.
The safety caps are ON by default. We strongly recommend that you do not disable them.
What it does
Gold Pullback Martingale is an automated trading robot designed for XAUUSD (gold) on MetaTrader 5. It opens a basket in the direction of the trend after a pullback. If price moves against it, it adds a limited number of ATR-spaced levels with a configurable lot multiplier. The whole basket is closed together at a basket take-profit or at one of several hard loss limits.
It can be attached to any symbol and any chart timeframe. Signals are read from a fixed signal timeframe (H1 by default), on closed bars only. There is no repainting and no look-ahead.
Entry logic (closed bars of the signal timeframe)
- Trend: the slow EMA (100) must have risen or fallen by at least 0.30 × ATR over the last 10 bars, and the close must be on the trend side of the slow EMA.
- Pullback: the bar touched the fast EMA (20) and closed back beyond it in the trend direction. For a buy, the candle must also be bullish; for a sell, bearish.
- Filters:
- Spread (as a fraction of ATR and/or in points).
- Trading hours (server time).
- Optionally no new baskets on Friday.
- Optional minimum ATR.
- Direction: buy, sell, or both.
- Only one basket per symbol and magic number is open at a time.
Martingale basket
- Starting lot: a fixed lot, or a lot per 1,000 of balance.
- Additional levels: a level is added when price moves against the worst entry by StepAtr × ATR × StepGrowth^(n-1). Spacing widens with each level by default.
- Lot size: each level's lot = starting lot × multiplier^n (default 1.50, allowed 1.0–3.0). Lots are rounded down to the broker's volume step.
- Basket take-profit: the basket closes when price is BasketTpAtr × ATR beyond the volume-weighted average price and the basket is in profit.
Safety caps (all ON by default)
| Cap | Default |
|---|---|
| Max levels per basket | 5 |
| Max lot of any position | 0.50 |
| Max total basket lots | 1.50 |
| Basket stop-loss, % of balance at basket start | 10% |
| Basket stop-loss in money | off (optional) |
| Equity drawdown stop from equity peak (closes basket and pauses) | 25%, pause 24 h |
| Server-side stop on every position, beyond the deepest possible level | 1.0 × ATR |
| Minimum margin level after adding a level | 300% |
| Max spread | 0.15 × ATR |
| Trading hours for new baskets | 02:00–22:00 server time |
| No new baskets on Friday | on |
| Max basket duration | off (optional) |
Order safety
Before every order the EA:
- Checks free margin with OrderCalcMargin and OrderCheck. It does not open or add a level if margin is insufficient.
- Respects volume min/max/step and the symbol volume limit.
- Respects stops and freeze levels and the trading session.
- Backs off after a rejected request.
The EA never modifies existing positions. Each position's stop-loss is set when it is opened.
Testing performed (honest results, MT5 Strategy Tester, JustMarkets demo data, 1:100)
All tests use default inputs and a 10,000 USD deposit unless stated otherwise.
XAUUSD H1, 2024-01-01 to 2026-10-20
| Model | Net profit | PF | Max equity DD | Baskets (lost) | Worst basket |
|---|---|---|---|---|---|
| Every tick based on real ticks | +1,761.40 | 1.21 | 1,887.92 (15.81%) | 633 (14) | -1,142.78 |
| 1-minute OHLC | +5,486.79 | 1.93 | 919.05 (7.21%) | 639 (12) | -606.86 |
- The real-tick result is much weaker than the generated-tick result. Treat the real-tick numbers as the more realistic ones.
- Gold rose strongly during this period, which may flatter a trend-following strategy.
- Stress test (caps disabled): multiplier 2.0, 8 levels, no basket SL, no DD stop, no hard SL. Result: -9,613.17 USD, equity DD 101.3%.
- Other symbols (2026, default inputs, 1-minute OHLC):
| Symbol / timeframe | Net | PF |
|---|---|---|
| EURUSD H1 | +111.13 | 1.60 |
| EURUSD M1 (Sep–Oct) | -11.80 | 0.77 |
| GBPUSD M30 | +189.37 | 1.62 |
| USDJPY H1 | +94.58 | 1.45 |
The EA was designed for gold. These runs only check that it works safely elsewhere.
- 1 USD deposit: no trades. The EA logs "not enough free margin" and does not send orders.
No forward test on a live or demo account has been done yet. Results with your broker's spreads, commissions and execution will differ.
Recommendations
- Use on XAUUSD with a hedging account and a deposit large enough that a full 5-level basket at your starting lot is a small part of equity. At the default 0.01 starting lot, we suggest at least 5,000–10,000 USD.
- Run a demo account for several weeks before going live.
- Run only one instance per symbol and magic number.
- Netting accounts: only one basket direction is possible, and the EA has not been tested on netting accounts.
Inputs
Entry signal:
- Signal timeframe (default H1)
- Fast EMA (20)
- Slow EMA (100)
- Slope bars (10)
- Minimum slope × ATR (0.30)
- ATR period (14)
- Minimum ATR in points (off)
- Allowed direction
Martingale basket:
- Starting lot mode (fixed / per 1,000)
- Starting lot (0.01)
- Lot per 1,000 (0.01)
- Multiplier (1.50)
- Step × ATR (1.00)
- Step growth (1.20)
- Basket TP × ATR (0.60)
Safety caps:
- Max levels (5)
- Max lot (0.50)
- Max basket lots (1.50)
- Basket SL % (10)
- Basket SL money (0 = off)
- Max equity DD % (25)
- DD pause hours (24)
- Hard SL buffer × ATR (1.0)
- Minimum margin level % (300)
- Max basket hours (0 = off)
Filters:
- Max spread × ATR (0.15)
- Max spread in points (off)
- Start hour (2)
- End hour (22)
- No new baskets on Friday (true)
Execution:
- Magic number
- Max slippage
- Order comment
- Show chart panel
Risk disclosure
Trading leveraged products such as gold CFDs carries a high level of risk and may not be suitable for all investors. Martingale and averaging strategies increase position size while a trade is losing. They can produce long series of small gains followed by a single large loss. This product does not guarantee profit, and the backtest results shown are hypothetical. You are solely responsible for your trading decisions and settings.
Keywords: martingale, gold, XAUUSD, averaging, basket, grid, ATR, trend pullback, EMA, expert advisor, MT5, risk caps, drawdown stop
