To backtest in MetaTrader 5, open the Strategy Tester (View → Strategy Tester or Ctrl+R), choose the Expert Advisor, the symbol, the timeframe and the dates, set the modelling to “Every tick based on real ticks”, enter your account’s deposit and leverage, and click Start. Clicking the button is the easy part; the hard part is making the simulation look like the real market. Here is every setting, and the mistakes that distort a backtest the most.
- Before you start: the robot and your broker’s price history
- How to backtest in MetaTrader 5, step by step
- Strategy Tester modelling modes: which one to use
- Inputs, optimization and forward testing in the tester
- Checking the backtest report: settings and history quality
- Common mistakes that distort a MetaTrader 5 backtest
- The AUREUM backtest: what it publishes
- Frequently asked questions about backtesting in MetaTrader 5
Before you start: the robot and your broker’s price history
The tester only sees robots in the MQL5 ▸ Experts folder, the ones listed in the Navigator under Expert Advisors; if yours isn’t there yet, follow how to install an Expert Advisor in MetaTrader 5. In the tester, the robot trades a simulated deposit: it doesn’t send any orders to your account.
Prices come from your broker’s server, and the tester downloads them when it starts. To see how far back they go, open View → Symbols (Ctrl+U), go to the Ticks tab, pick the symbol and a date range, and click Request. If the ticks start two years ago, a five-year backtest will only have real ticks for the last two. The first download takes a while: ticks take up far more space than one-minute bars.
How to backtest in MetaTrader 5, step by step
With MT5 open and logged in to your account, live or demo:
- Open the tester. Go to View → Strategy Tester or press Ctrl+R (on a Mac too, where MT5 shortcuts use Ctrl; see MetaTrader 5 on Mac), or right-click the robot in the Navigator and choose Test. For a first backtest, stay on the Settings tab.
- Robot, symbol and timeframe. Under Expert, pick your Expert Advisor; then the symbol and the timeframe: for gold, your broker’s XAUUSD (it may be called GOLD or carry a suffix), and the timeframe the robot asks for, H1 for example.
- Dates. Under Date, choose a preset range (last year, entire history…) or “Custom period”. Before the start date, the tester loads enough history to build at least 100 bars; if there isn’t enough, it moves the start later and notes it in the Journal.
- Modelling. For the result that counts, “Every tick based on real ticks”; the modes are covered in the next section.
- Deposit and leverage. Under Deposit, enter the amount and the currency (your account’s by default) and, next to it, the leverage. Use what you’ll really have: a robot that sizes its lots from the balance doesn’t trade the same way with 1,000 as with 100,000, and the leverage you get on gold depends on your broker’s regulator: 1:20 for retail clients in the EU and the UK (see gold leverage). Leave “profit in pips” unticked: it doesn’t calculate swaps or commissions.
- Delays. “Zero latency, ideal execution” fills every order at the requested price, which doesn’t happen in a live account. Run the test again with “Random delay” or a custom delay in milliseconds (MT5 shows your last ping to the server).
- Inputs and start. The Inputs tab holds the robot’s settings: use the ones its developer recommends. With optimization disabled, click Start.
The results show up in the Backtest tab (the report), the Graph tab (balance and equity) and the Journal tab (messages from the robot and the tester).
Visual mode: watch the robot trade
If you tick Visualization, you watch the robot trade candle by candle on a chart, with its indicators and orders: the best way to check that it respects its stop and doesn’t open trades at odd hours. It can’t be used for optimization, it only runs on local agents, and you can’t change that chart’s timeframe.
Strategy Tester modelling modes: which one to use
The modelling decides which prices the robot sees inside each candle, and it’s the setting that changes the result most when the robot uses tight stops or a trailing stop: when a candle touches both the stop and the target, only real ticks tell the tester which came first; the other modes infer it from the bars. These are the modes:
| Mode | What it does and when to use it |
|---|---|
| Every tick based on real ticks | Replays the ticks your broker recorded, with their variable spread. According to MetaQuotes, it’s the closest to real conditions. The test that counts. It’s slow, and the first run downloads every tick in the period. |
| Every tick | Generates ticks inside each one-minute bar, with a fixed spread for each minute. It’s the most accurate and the slowest of the modes that generate prices. For periods with no real ticks in your broker’s history. |
| 1 minute OHLC | At most four prices per one-minute bar: open, high, low and close. For screening ideas and optimizing fast, if the robot doesn’t care what happens inside the minute. |
| Open prices only | The robot only acts at the open of each bar on the chosen timeframe. Stops and pending orders may fill at a price other than the one set. For quick, rough checks. Random delay isn’t available. |
The fifth mode, “Math calculations”, loads no prices and generates no ticks: it’s no use for a trading backtest. The rule of thumb: fast modes are for ruling ideas out, and when they disagree with real ticks, real ticks win. And even if you choose real ticks, the minutes where your broker has no ticks, or where they don’t match the one-minute bars, are generated as in “Every tick”.
Inputs, optimization and forward testing in the tester
Optimizing means rerunning the backtest with many combinations of inputs. On the Inputs tab, tick each input you want to vary and set its start value, step and stop value. Then, back on Settings, choose the type under Optimization:
- Slow complete algorithm: tests every combination. Exhaustive, but the time explodes with each input you add.
- Fast genetic based algorithm: looks for the best combinations without testing them all, according to the Criterion you choose: Balance max, Sharpe Ratio max and so on.
- Every symbol in Market Watch: the last option runs the same inputs on each symbol selected in that window.
The combinations appear in the Optimization Results and Optimization Graph tabs. How MT5 spreads the work across cores and agents is covered in MetaTrader 4 vs MetaTrader 5; whether the best combination is genuinely good or just fits that stretch of the past (overfitting), in backtesting and overfitting.
Forward testing inside the tester
The Forward setting holds back the end of the date range: half, a third, a quarter, or everything from a date you choose. During optimization, the tester searches for inputs in the first part and runs the best combinations through the second, which they never saw; their results appear in the Forward tab. If they collapse there, the inputs were tailored to the past. It doesn’t replace testing the robot in today’s market: see demo or live account.
Checking the backtest report: settings and history quality
Before you look at how much the robot made, check in the report on the Backtest tab that the symbol, timeframe, dates, deposit and leverage are the ones you set, and look at History Quality. With real ticks, the report shows it as a percentage of “real ticks” (for example, “100% real ticks”), but it doesn’t measure how much of the period was tested on them: MetaQuotes calculates it from one-minute data, comparing correct bars with incorrect ones (gaps count as incorrect). A 100% doesn’t guarantee that the whole period was tested on real ticks; the Journal flags the generated minutes with messages such as “real ticks absent…” or “real ticks discarded…, every tick generation used”.
Then come the metrics (net profit, profit factor, drawdown, number of trades), which you read together: we explain them in how to read the Strategy Tester report and in what is drawdown.
Common mistakes that distort a MetaTrader 5 backtest
- Incomplete history. You ask for six years and your broker only has ticks for two: the rest is tested on generated ticks, or the start is pushed back. Check the history before (View → Symbols) and the Journal after.
- A fixed spread per minute. With generated ticks, the tester uses a fixed spread within each minute and doesn’t see it widen on news; with real ticks, it does. What that costs on gold, in spread, slippage and commissions.
- Low-fidelity modelling. Validating a robot with tight stops or a trailing stop on “Open prices only” or “1 minute OHLC”: the tester doesn’t know what happened inside the candle.
- No commissions. The button next to Delays opens “Trade Settings”: on its Commissions tab, with “Use custom settings” unticked, your account’s commissions apply; tick it and the ones you enter in the table apply instead. Check that they show up in the report. With a per-lot commission, the difference adds up trade after trade.
- Ideal execution. With zero latency, every order fills at the exact price. Run the test again with a delay and compare.
- Another broker’s data. Each broker has its own history, spread and trading hours: test on the broker you’re going to trade with.
The AUREUM backtest: what it publishes
AUREUM is an Expert Advisor for gold (XAU/USD) in MetaTrader 5. Its homepage publishes the MT5 Strategy Tester report on XAU/USD history from 2020 to 2026, on H1 and with real spreads: 439 trades, a profit factor of 1.49 and a maximum drawdown on balance of 21.84%, from $5,000 to $25,524 in the simulation. It’s a backtest, not a live account. According to the homepage, the strategy was also validated with Monte Carlo and Walk-Forward on periods it didn’t use during its creation.
What you’ve seen here helps you read that report, or any other, with the right questions: what spread it was run with, how many trades are behind it and how far it fell. As its legal notice points out, actual performance may differ due to slippage, commissions, spreads, latency and broker conditions.
Frequently asked questions about backtesting in MetaTrader 5
How do you open the Strategy Tester in MetaTrader 5?
From the View → Strategy Tester menu or with Ctrl+R, on a Mac too. You can also right-click the robot in the Navigator and choose Test: the tester opens with that Expert Advisor already selected.
Which modelling mode is the most reliable in MT5?
“Every tick based on real ticks”, which replays the ticks your broker recorded, variable spread included. It’s slow (the first run downloads every tick in the period), and if your broker is missing the ticks for a minute, or they don’t match its one-minute bars, the tester generates that minute as in “Every tick”.
Does the Strategy Tester charge commissions?
It can, but check. In “Trade Settings” (the button next to Delays), Commissions tab: with “Use custom settings” unticked, your account’s commissions apply; tick it and the ones you enter apply instead. If you tick “profit in pips”, neither commissions nor swaps are calculated.
What is forward testing in the Strategy Tester?
It sets aside the last part of the period (1/2, 1/3, 1/4 or from a date) to check the optimized inputs on data they didn’t see during optimization. If the result collapses in that stretch, the inputs were tailored to the past.
What deposit and leverage should I set in the tester?
Those of the account you’re going to trade: a robot that sizes its lots from the balance doesn’t trade the same way with 1,000 as with 100,000. The EU (and the UK) cap retail gold leverage at 1:20; elsewhere it depends on your broker’s regulator.
A backtest is a simulation on past data and doesn’t capture everything that happens in a live account: past or simulated results do not guarantee future results. Leveraged gold trading carries a high level of risk and you can lose some or all of your capital. The menus quoted are those of the English version of MT5 at the time of publication and may change. The AUREUM figures come from a simulation (backtest), not from a live account. This content is educational and is not financial advice.
AUREUM: its backtest report, as is
Software that trades XAU/USD in your own MetaTrader 5 account. Its homepage shows the 2020–2026 Strategy Tester report, drawdowns included: a maximum drawdown on balance of 21.84% across 439 trades. It’s a simulation, not a live account.
See the backtest report →