MT5 Backtesting: How to Test an EA in the Strategy Tester

Published November 17, 2026 · Updated November 17, 2026 · In Bot Development

MT5 backtesting means running an Expert Advisor (EA) over past prices in the MetaTrader 5 Strategy Tester to see how its rules would have traded. How honest the result is depends on four settings: the modelling mode, the costs, the dates you hold back for a forward check, and how hard you optimise. Every Strategy Tester fact below comes from MetaQuotes’ own help pages and MQL5 docs, checked on 17 November 2026.

A backtest works as a filter. It can show that rules lose money on past data, break on one symbol or depend on one lucky month. It cannot tell you what the EA will earn next month.

Set up a test in the Strategy Tester

In the Navigator window, right-click the EA and choose Test. The Strategy Tester opens with that EA already selected. On the Settings tab you then fill in:

Your first MT5 backtesting run on a symbol is slow because the terminal downloads all the history it can get for it. When a test then begins later than the date you typed, read the Journal before you blame the EA. The tester moves the start date by itself when history is short.

Pick a modelling mode for MT5 backtesting

The modelling mode decides which prices the EA sees between bar opens. MetaQuotes lists five modes. The last column is our own suggestion.

Mode Prices the EA sees Use it for
Every tick based on real ticks Ticks your broker recorded, with a spread that can change inside a minute Final checks, scalpers and tight stops
Every tick Ticks generated from minute bars, up to 11 reference points per bar Intrabar exits when real ticks are missing
1 minute OHLC Open, high, low and close of each minute bar Quick first passes
Open prices only The open of each bar on the test timeframe EAs that act once per bar, at the open
Math calculations No prices. Only OnInit(), OnTester() and OnDeinit() run Pure maths with no market data

Real ticks have one gap. If a minute has no tick data, the tester generates ticks for that minute in Every tick mode. If ticks exist but the minute bar is missing, it ignores those ticks, because MetaQuotes treats minute data as the more reliable source.

The fast modes flatter tight stops. In Open prices only and 1 minute OHLC, pending orders, stop loss and take profit fill at the exact price written in the order, since the ticks in between never exist. A 5-point stop on a fast candle looks perfect there. Open prices only also blocks Random delay, and the EA cannot read timeframes lower than the one you test on.

MT5 backtesting modelling modes compared: real ticks, every tick, 1 minute OHLC, open prices only and math calculations, with the prices each one gives the EA
The five modelling modes and the prices each one gives your EA during MT5 backtesting.

Spread, commission and execution delay

An EA that makes a few points per trade can lose all of it to costs. In MT5 backtesting, each cost comes from a different place.

Spread comes from history. MetaQuotes says it is not modelled, and if the stored value is zero or below, the last known spread is used. With generated ticks, the Ask is the Bid plus the spread fixed in that minute bar, so the spread cannot widen inside the minute. Real ticks keep the broker’s own spread changes, which matters for news trades.

Commission is not in the price history, so you add it in the tester’s advanced settings. It can be charged per lot or per deal, in money, percent or points, on entries, exits or both. Copy the real commission for the account type you plan to trade. Profit in pips speeds testing up, but MetaQuotes says swap and commission are dropped in that mode, so keep it for rough passes.

The Delays setting adds lag between a trade request and its fill. No delay fills at the requested price. Random delay waits 0 to 8 seconds about 90% of the time and 9 to 18 seconds the rest. Fixed delay uses your own value or the ping the platform measures to your trade server. It applies to the EA’s own trade actions only, not to pending orders the server triggers.

Where the MT5 Strategy Tester takes spread, commission and execution delay from, and what you have to set yourself
Only commission and delay are yours to set. Spread comes from the price history.

Keep a forward period the optimiser never sees

MetaQuotes describes forward testing as running the EA again on a different time period. Set Forward to 1/2, 1/3, 1/4 or Custom and the tester splits your date range. The later part is always the forward period. Optimisation happens only in the earlier part.

After the optimisation, the tester re-runs the best passes on the forward dates: 10% of passes in a full search and 25% in genetic optimisation. It sends at least 256 passes forward, or all of them if the run had fewer. Results appear on a separate Forward tab, and a vertical line marks the forward start on the optimisation graph.

The aim, in MetaQuotes’ words, is to avoid parameters fitted to one stretch of history. A pass that ranks well in both periods tells you more than the single best backtest. When a pass tops the back period and falls apart forward, it was fitted to noise. Pick the split before you look at any result. Once you move the forward start after seeing it, those dates stop being unseen data.

MT5 Strategy Tester Forward setting: how 1/2, 1/3, 1/4 and Custom split one date range into a backtest period and a forward period
The forward share always sits at the end of the range, after the dates used for optimisation.

Optimisation and over-fitting

Optimisation runs the EA many times with different inputs. For each input you tick, you set a start value, a step and an end value, and the tester shows how many combinations that makes. You can choose from three modes:

Genetic runs rank passes by one criterion: Balance max, Profit Factor max, Expected Payoff max, Drawdown min, Recovery Factor max, Sharpe Ratio max, Complex Criterion max or Custom max. Custom max uses the number your EA returns from OnTester(). That lets you score passes your own way, for example profit divided by equity drawdown, with a penalty when the trade count is low.

Over-fitting is the usual trap in MT5 backtesting, and a few habits keep it in check. Optimise as few inputs as you can, because each extra one multiplies the combinations and the odds of a lucky fit. Look at the neighbours of the best value too. If it sits on a narrow spike and the values beside it lose, treat it as luck. A great result from 30 trades says little, so ask for enough trades. Then judge passes on the Forward tab. Running the All symbols mode as a check also helps, since rules that work on one symbol only need a reason.

What to read in the Strategy Tester report

Start with the data, then the risk, then the profit. These definitions follow the MetaTrader 5 report help page:

Report line What it measures What to ask
History Quality Share of correct one-minute data in the tested period Are there gaps where trades happened?
Total Trades Trades that closed with a profit or a loss Are there enough for the other numbers to mean much?
Profit Factor Gross profit divided by gross loss Does it hold on the Forward tab?
Expected Payoff Average result per deal Is it well above spread plus commission?
Equity Drawdown Maximal Largest fall from a local equity high to the next low Could you sit through it with real money?
Recovery Factor Profit relative to the maximum drawdown How much pain bought the profit?
Sharpe Ratio Return over its standard deviation, with a risk-free rate of zero Is the curve steady or jumpy?
LR Correlation How closely the balance curve follows a straight line Did one period carry the whole result?
Z-Score Whether wins and losses come in runs Beyond plus or minus 3, is there a pattern you can use?

Then open the graphs. MFE and MAE show how far each trade moved in your favour and against you while it was open, which tells you whether the stops and targets suit the moves. Entries by hours, weekdays and months show if the result comes from one session or one month.

Nine Strategy Tester report lines to check first, from History Quality and Total Trades to Sharpe Ratio, LR Correlation and Z-Score
In an MT5 backtesting report, data quality and trade count come first, because every other line depends on them.

Where the tester differs from a live account

Some EA code behaves differently in MT5 backtesting than on a live account. These points come from MetaQuotes’ testing features page:

Live trading adds what no setting fully copies: requotes, slippage on busy candles, rejected orders and server outages.

From MT5 backtesting to a demo account

  1. Run a final test on real ticks with your broker’s commission, a delay close to your ping and a forward period.
  2. Load the same inputs and set file on a demo account at the same broker. Let it run long enough to collect a useful number of trades.
  3. Backtest the demo dates and compare trade by trade: entry times, fill prices and the spread paid. A gap points to a bug or a missed cost.
  4. Go live at the smallest size the broker allows, with the same settings.
Four stages for an Expert Advisor: backtest with real costs, forward check, demo account at the same broker, then a small live account
Each stage uses the same inputs, so any change in results points to data, costs or code.

If the EA does not exist yet, our guide on how to build a trading bot covers writing rules a tester can check. Coming from MetaTrader 4? Read MT4 vs MT5 first, then look at MT4 to MT5 conversion. To judge EAs sold by others, see what “best forex EA” claims hide. Our MT5 EA developers can build your strategy and run these tests with you. Send your rules on WhatsApp for a fixed quote.

MT5 backtesting FAQ

Why did my MT5 test start later than the date I set?

The tester needs at least 100 bars of the test timeframe before it starts, and for D1 and lower it loads history from the start of the previous calendar year. Without enough data it moves the start date forward and says so in the Journal. Testing on a lower timeframe reduces these shifts.

Is real-tick testing available for every symbol?

It depends on the ticks your broker has stored for that symbol, and the first download of real ticks can take a long time. After the run, History Quality in the report shows how clean the minute data was.

What profit factor is good in MT5 backtesting?

Profit factor is gross profit divided by gross loss, so a value above 1 means the test made money. No value predicts future results. Read it next to the trade count and equity drawdown, and compare the Forward tab with the backtest.

How does the Strategy Tester calculate the Sharpe ratio?

It divides return minus a risk-free rate by the standard deviation of return, and the tester sets the risk-free rate to zero. MetaQuotes reads below 0 as unprofitable, 0 to 1 as indefinite, 1 and up as good, and 3 and up as very good. Those bands describe the test period only.

Can one test cover several symbols?

Yes. When a multi-currency EA requests another symbol, the tester adds it to its emulated Market Watch and downloads its history from the terminal. Each symbol gets its own ticks. Use Every tick or 1 minute OHLC for these EAs, since Open prices only cannot keep bars on different symbols in step.

Is MT5 backtesting better than testing in MT4?

MT5’s tester can use your broker’s real ticks, run several symbols inside one EA and spread optimisation over local agents, remote agents and the MQL5 Cloud Network. Which platform suits you depends on your broker and your code, which our MT4 vs MT5 comparison covers.

Risk warning: Trading forex, CFDs and other leveraged products carries a high risk of loss. Backtest, forward-test and demo results are hypothetical and do not predict live results. Automated trading does not remove market risk. This article is for education only and is not investment advice.

Want this built for you?

We develop it as a service — reliable, tested, and yours to own.

Message Us on WhatsApp
WhatsApp