MT5 & platform

MT5 Strategy Tester for Gold: How to Backtest an XAUUSD EA Step by Step (and Trust the Result)

The MetaTrader 5 Strategy Tester can replay years of gold prices through an expert advisor (EA) in minutes. It can also produce a beautiful equity curve that falls apart the first week live. The difference is in a few settings and in how you read the report. This guide walks through every step on XAUUSD, in plain words.

Gold spot$3,528.2−99.8 (−2.75%)NextUS Q3 GDP (second estimate) and October PCE inflationin 4d 20h · Wed 13:30 GMTMarket opencloses in 4h 34mRange$123.2
Gold price, last 12 monthsGold price, last 12 monthsHigh $5,318 (29 Jan 2026) · low $3,536 (20 Nov 2026) · 12-month change −14.2%$4,000$4,500$5,000$3,536Dec ’25Feb ’26Apr ’26Jun ’26Aug ’26Oct ’26
COMEX gold, daily closes, last 12 months · data to 20 Nov 2026 · xauusdglobal.com

Short answer: press Ctrl+R in MetaTrader 5, choose your expert advisor (EA), the gold symbol, a timeframe and dates, and set Modelling to “Every tick based on real ticks”. Add a random delay, use the deposit and leverage you really have, then read the report’s profit factor, maximum drawdown, number of trades and history quality. Finally, keep some recent months aside and test on them separately. A result that only works on the months you tuned it on is not a result.

Why gold needs extra care in the tester

Gold is a fast market. Over the 14 trading days to 12 November 2026, COMEX gold’s average daily range (ATR) was $89.7 an ounce on our daily data. In the busiest hours of the day, a single hour often moves $20 to $30. Inside one minute at a data release, gold can move several dollars.

That matters because the tester has to guess what happened inside each bar. If it guesses wrongly, your EA “fills” a stop or a target that could not really have been filled. On a slow market the error is small. On gold it can turn a losing EA into a winning one on paper.

Step 1: open the tester and choose the basics

  1. Press Ctrl+R (or View → Strategy Tester).
  2. On the Settings tab, choose Expert: the EA you want to test.
  3. Choose Symbol: the gold symbol on your account. It may be XAUUSD, GOLD or XAUUSD with a suffix. Our symbol names guide explains the differences.
  4. Choose the timeframe the EA was written for.
  5. Set the Date range. Use at least two to three years if the history exists, so the test sees different kinds of market.

Before you start, open the symbol’s Specification window (right-click the symbol in Market Watch). Check the contract size (usually 100 ounces per lot), digits and minimum lot. Our contract specifications guide explains every line. If you test on one account and trade on another with different specifications, the results will not match.

Step 2: pick the right modelling mode

The Modelling setting decides how the tester builds prices inside each bar.

Mode What it does Use it for gold?
Every tick based on real ticks Replays stored real ticks, with their real bid and ask Yes, for the final test
Every tick Generates ticks from one-minute bars Rough checks only
1 minute OHLC Uses only the open, high, low and close of each minute Quick screening only
Open prices only Uses only each bar’s opening price Only for EAs that act at bar open
Math calculations No prices at all Not for trading tests

Real-tick mode is slower and needs tick history from your account’s server. If the history is missing for some dates, the tester falls back to generated data, and the report’s history quality drops. Always check that figure.

What about the spread?

In real-tick mode the spread comes from the stored bid and ask prices, so it widens at news and at the daily rollover as it did in the past. That is the most honest option.

In the generated modes the tester uses a spread stored with each bar. That can be smaller than what you would really pay in a fast minute. Many careful testers make a custom symbol with a fixed, wider spread to see whether the EA still works when costs are worse than average. If an EA only works with a tiny spread, it probably will not survive live. Our page on spreads, commissions and swaps shows what costs to include.

Step 3: delays, deposit and leverage

  • Delays: choose a random delay instead of “zero latency”. Real orders take time to reach the server, and on gold a few hundred milliseconds can mean a worse price.
  • Deposit: use the amount you will really trade with. A $100,000 deposit hides drawdowns that would end a $1,000 account.
  • Leverage: set what your account really allows. Too much leverage in the test can let the EA open trades you could not open live.
  • Commission: if your account charges a commission per lot, make sure the test includes it. Check the symbol settings or add it in a custom symbol.

Step 4: run it and read the report

Press Start. When it finishes, open the Backtest (report) tab. Here are the numbers that matter most, in plain words:

Report line What it means A warning sign
Total net profit Profit after costs in the test Big profit from very few trades
Profit factor Gross profit ÷ gross loss Above about 3 on gold often means overfitting
Expected payoff Average profit per trade Smaller than a normal spread
Maximum drawdown (balance and equity) Worst fall from a peak A drawdown you could not live through
Total trades Number of trades Under about 100
Largest loss vs average loss Size of the worst trade One loss many times the average
History quality Share of good price data Well below 100%

Then look at the graph. A smooth line that only climbs is a reason for suspicion, not celebration. Real strategies have flat and losing periods.

A worked example (hypothetical)

Imagine an EA test shows 140 trades, a win rate of 55%, an average win of $120 and an average loss of $100. The expectancy per trade is 0.55 × $120 − 0.45 × $100 = $66 − $45 = $21. If your real costs (spread plus commission) are $8 per trade more than the test assumed, the true edge is about $13. If they are $25 more, the edge is gone. The expectancy calculator and our trading maths lesson show this in detail.

Step 5: optimisation without fooling yourself

The tester can try thousands of setting combinations and show you the best one. That is where most backtests go wrong. With enough tries, some settings will always look great on the past by luck. This is called overfitting (or curve-fitting).

Simple rules that help:

  1. Use the Forward option. MT5 can keep part of your date range aside (for example the last third) and test the best settings on it. If the forward result is much worse, the settings were fitted to noise.
  2. Prefer broad areas. If a stop of 300 points works but 280 and 320 fail, that is luck. Look for settings where nearby values work too.
  3. Change one thing at a time. Testing ten inputs at once almost guarantees a fit.
  4. Test different markets. Gold in 2025 and 2026 included sharp rallies and sharp falls. A good EA should survive both, even if it earns less in one.
  5. Write down every test. If you ran 50 versions and show only the best, you have hidden 49 failures, even from yourself.

Our full guide to backtesting a gold strategy covers sample size, look-ahead bias and the other traps.

Step 6: demo forward test before money

A backtest is only the first filter. Before trading money, run the EA on a demo account for at least a few weeks with the same settings. Compare:

  • the number of trades with what the tester predicted for a similar period,
  • the average spread and slippage on real fills,
  • how the EA behaved at news times and at the weekly open.

If the live demo looks very different from the tester, find out why before going further. Our EA and bot checklist lists the questions to ask about any automated system, including ones you buy.

Common mistakes

  • Testing with “Open prices only” on an intraday EA. It cannot see stops and targets hit inside the bar.
  • Ignoring history quality. A 40% quality test is mostly made-up prices.
  • Too short a period. Three months of a trending market proves very little.
  • Huge deposit, tiny lot. Drawdowns look small and the real risk is hidden.
  • Trusting a bought EA’s screenshots. Run the test yourself on your own account’s data.

Educational content only, not financial advice. A backtest shows the past under assumptions; it does not promise future results.

Frequently asked questions

How do I open the Strategy Tester in MT5?

Press Ctrl+R, or open the View menu and choose Strategy Tester. A panel opens at the bottom of the terminal with a Settings tab, where you choose the expert advisor, the symbol, the timeframe, the dates and the modelling mode.

Which modelling mode is best for gold in MT5?

Every tick based on real ticks, if your account’s server has tick history for XAUUSD over your test dates. Gold moves several dollars within one minute around news, so modes built from one-minute bars or open prices can show fills that were not possible. Use the faster modes only for a first rough look.

How does MT5 handle the spread in a backtest?

In real-tick mode the tester uses the bid and ask prices stored in the tick history, so the spread changes as it did in the past. In the generated modes it uses the spread stored with each bar, which can be smaller than what you would pay live at news times. Many testers add a safety margin by testing on a custom symbol with a fixed wider spread.

What does history quality mean in the MT5 report?

It shows how much of the test used good price data. A figure near 100% with real ticks is what you want. If it is low, the test used gaps or generated prices, and the result is less reliable.

Why is my EA profitable in the tester but losing live?

The usual causes are an over-optimised setting that only fitted the past, a test with no realistic spread, commission or slippage, a mode that used generated ticks, or a test period that only had one kind of market. Run a forward test on dates the optimisation never saw before trusting any result.

Can I backtest gold in MT5 for free?

Yes. The tester is built into MetaTrader 5 and a demo account is usually enough to download history. The quality of tick history depends on the server you connect to, so compare the history quality figure across tests.

How many trades do I need in a backtest?

There is no magic number, but under about 100 trades the result is mostly luck. Aim for several hundred trades across rising, falling and sideways gold markets, and check that the result does not depend on one or two huge winners.

Sources and further reading

External sites are independent of XAUUSD Global. Check dates and data yourself.

Comments

No comments yet.

Leave a comment

Comments are checked before they appear. Be respectful: no promotion, no trade signals. Rules · Privacy. No email needed.