How to backtest a gold EA: data, spreads and honest results
Every gold robot comes with a beautiful backtest. Almost none of them survive contact with the live market in the same shape. The gap isn't usually dishonesty — it's testing done badly. Here's how to run a backtest that actually tells you something.
Why most gold EA backtests are misleading
A backtest replays history against your EA's rules. That sounds objective, but three assumptions quietly inflate the result:
- Perfect spreads. Testers typically apply a fixed, tight spread. Real gold spreads widen sharply around news and the daily rollover.
- Perfect fills. No slippage, no requotes, no latency — none of which is true live.
- Hindsight tuning. Settings get adjusted until the curve looks great on that data.
Gold makes all three worse than usual, because XAU/USD is more volatile and more spread-sensitive than a major forex pair. That's why a robot can show a flawless backtest and still lose live — a point we covered in are gold trading EAs actually profitable?
Step 1 — Start with quality data
Garbage data produces confident nonsense. What to aim for:
- MT4: at least 90% modelling quality; 99% if you import real tick data with a tool like Tickstory or TDS.
- MT5: use "Every tick based on real ticks" — it's more accurate than MT4's modelled ticks and runs multi-threaded.
Step 2 — Use a realistic spread
This is the single biggest fixable error. Testing gold at a 10-point fixed spread when your broker averages 20–30 (and 100+ at news) will flatter almost any strategy — and it destroys fast strategies completely.
Set the spread to your broker's realistic average for XAUUSD, or use variable/real spread if your data supports it. Then re-run the test with a spread 50% worse than average. If profitability disappears, the edge was never robust.
Step 3 — Test long enough, across different conditions
One good year proves nothing. Aim for 1–3 years minimum, and make sure the window includes:
- A strong trending phase and a choppy ranging phase
- At least one high-volatility shock period
- Enough trades to be statistically meaningful — a few dozen is not a sample
Step 4 — Read the right numbers
| Metric | Why it matters |
|---|---|
| Maximum drawdown | The worst losing stretch you'd have to sit through. The most important number by far. |
| Profit factor | Gross profit ÷ gross loss. Below ~1.2 is fragile; suspiciously high often means curve fitting. |
| Number of trades | Small samples are luck, not evidence. |
| Equity curve shape | Smooth and gradual beats a curve made by two lucky trades. |
| Total profit | The least useful number on its own — it's what marketing shows you. |
Once you know the drawdown, you can size properly — see how to set risk per trade on a gold EA.
Step 5 — Avoid over-optimisation (curve fitting)
Optimisation finds the settings that would have worked best in the past. Push it far enough and you've fitted history, not the market. Two safeguards:
- Out-of-sample testing. Optimise on one period, then test those settings on a separate period you never touched.
- Prefer robust settings. If a parameter only works at exactly 14 and collapses at 13 or 15, that's a fluke — pick values that work across a range.
Step 6 — Forward test on demo (the only real proof)
After the backtest, run the EA on a demo account for several weeks in current conditions. This is where real spreads, slippage, execution and news behaviour show up — none of which a tester can fully model. If demo results roughly match the backtest's character (not its exact profit), you have something worth a small live account.
Need to get the EA installed first? See how to install a gold EA on MT4 & MT5 or the MT5 setup guide.
MT4 vs MT5 for backtesting
Both work, but MT5's tester is meaningfully better for gold: it supports real tick data natively, runs multi-threaded (much faster), and handles multi-symbol testing. MT4 can reach 99% quality but needs imported tick data and more setup. If you have the choice, backtest on MT5.
Frequently asked questions
How do I backtest a gold EA on MT4 or MT5?
Open the Strategy Tester, pick the EA and XAUUSD, set the date range, use every-tick (real ticks on MT5) modelling and a realistic spread, then run it and review the report — starting with maximum drawdown.
What modelling quality should it have?
90% minimum on MT4, 99% with imported real tick data. On MT5 use "every tick based on real ticks". Below 90% on MT4 isn't trustworthy for gold.
Why do backtests look better than live results?
They assume tight fixed spreads and perfect fills, and settings are often over-fitted to past data. Gold's spread widening around news makes the gap worse.
How long should I backtest?
At least 1–3 years, covering trending, ranging and high-volatility periods, with enough trades to be meaningful.
What metrics actually matter?
Maximum drawdown first, then profit factor, trade count and equity-curve shape. Total profit alone is the least informative.
What is curve fitting?
Tuning settings until they fit history perfectly. Guard against it with out-of-sample testing and robust parameter ranges.
Is a backtest enough before going live?
No. Always forward-test on demo for several weeks first, then start small.
Bottom line
A backtest is a hypothesis, not proof. Done properly — good tick data, honest spreads, a long and varied period, drawdown-first analysis, and no curve fitting — it tells you whether a gold EA is worth forward-testing. Done badly, it's a marketing image. The discipline is simple: make the test harsher than reality, and let the demo account have the final word.
Affiliate disclosure: we earn a commission when you open and fund an account through our partner links, at no extra cost to you.