To backtest an Expert Advisor in MetaTrader 5, compile the EA in MetaEditor, open the Strategy Tester with View → Strategy Tester (or Ctrl+R), choose the EA, the symbol and timeframe it trades, a date range and a modelling mode, set a realistic deposit and leverage, then press Start and read the report on the Backtest tab. The tester replays historical prices through your EA exactly as if they were arriving live, opening and closing every trade your rules would have made, and then summarises the result: net profit, profit factor, expected payoff, drawdown and the number of trades. Two settings decide whether that summary means anything. The modelling mode controls how realistically price moves inside each bar, and the date range controls how much market behaviour the EA is tested against. Get those right, check the Journal for errors, and an MT5 backtest becomes a fast, free first filter for any automated trading strategy - not proof that it will make money, but a reliable way to find the ones that clearly won't.
Step 1: Compile the EA so the tester can see it
The Strategy Tester only runs compiled Expert Advisors, so an .mq5 source file has to be compiled into an .ex5 file first. Put the .mq5 file in the MQL5\Experts folder (File → Open Data Folder), refresh the Navigator panel, right-click the EA and choose Modify to open it in MetaEditor, then press F7. The Errors count at the bottom must read 0 - warnings are fine, errors are not. If the EA is missing from the tester later, this step is almost always the reason.
Step 2: Open the Strategy Tester and choose the EA, symbol and timeframe
The MT5 Strategy Tester opens from View → Strategy Tester or with Ctrl+R, and its Settings tab holds everything a single backtest needs. Pick your EA in the Expert field, then set Symbol and timeframe to the market and chart period the strategy was designed for. If the EA's rules name a specific instrument, test on that same instrument - a backtest on a different pair tells you about a strategy you are not going to run.
Step 3: Pick a date range with room to spare
A backtest is only as informative as the market conditions inside its date range. Choose a custom period long enough to include different kinds of markets - trending stretches, quiet ranges, volatile weeks - and enough trades that one lucky result cannot carry the whole report. It is also worth keeping the most recent part of your history out of any tuning: when you optimize inputs, the tester's Forward option holds back a slice of the period and tests the chosen settings on it separately, which is one of the simplest guards against curve fitting.
Step 4: Choose the modelling mode
The modelling mode is the setting that most changes how trustworthy an MT5 backtest is, because it decides what price did between the open and close of each bar. The options trade speed for realism:
| Modelling mode | What it replays | When to use it |
|---|---|---|
| Every tick based on real ticks | Tick history recorded by the broker, including the real spread | The default choice whenever the broker provides tick history for the symbol |
| Every tick | Ticks generated by the tester from one-minute bars | A fallback when real tick history is not available |
| 1 minute OHLC | Only the open, high, low and close of each one-minute bar | Quick rough checks; less reliable for tight stops and targets |
| Open prices only | Only the opening price of each bar on the tested timeframe | Only for EAs that act exclusively at the open of a new bar |
| Math calculations | No price data at all | Mathematical calculations, not trading strategies |
The faster modes are tempting because they finish in seconds, but a stop loss or take profit that would have been hit inside a bar can be missed entirely when the tester never sees those intermediate prices.
Step 5: Set deposit, leverage, delays and inputs
Deposit and leverage should match the account you actually intend to trade, because they decide whether trades fit inside the available margin and how a fixed lot size compares to the balance. The Delays setting can stay at zero latency for a first run, but a random delay is closer to real execution, where orders do not fill instantly. If the EA has input parameters, set them on the Inputs tab and write the values down - a report you cannot tie back to its exact settings is hard to compare with the next one.
Step 6: Run it and read the report
After pressing Start, the Backtest tab shows a report, and a handful of its lines carry most of the information. Read them together rather than stopping at net profit:
| Report line | What it tells you |
|---|---|
| Total Net Profit | Gross profit minus gross loss over the whole test |
| Profit Factor | Gross profit divided by gross loss - above 1 made money (more on reading it) |
| Expected Payoff | The average result per trade (see expectancy) |
| Balance and Equity Drawdown Maximal | The deepest fall from a peak during the test (why drawdown matters) |
| Total Trades | How many trades the numbers above are based on |
Then open the Graph tab to see whether the balance grew steadily or in one lucky jump, and the Journal tab to look for errors such as rejected orders - a backtest full of failed trades is testing a different strategy than the one you think you built.
What an MT5 backtest still can't tell you
Even a carefully configured backtest replays stored history, so it cannot reproduce live slippage, requotes, connection drops or how your broker fills orders during a fast market. That is why the usual next step is a demo account: the same EA, real live prices, no real money - explained in backtesting vs. demo trading. On MetaTrader 4 the routine is similar (the tester also opens with Ctrl+R), and cTrader runs backtests from the Backtesting tab of its Automate section.
Backtesting an EA built with AlgoPuzzle
An EA exported from AlgoPuzzle goes through exactly the same steps, because the builder produces a standard .mq5 file and leaves testing to MetaTrader's own tester. Its README walks through installing and compiling it (Step 1 above). One detail matters for Step 4: the exported MT5 EA manages its stop loss and take profit itself, checking price on every incoming tick rather than sending them to the broker, so a tick-based modelling mode is the one that shows those exits realistically - Open prices only would check them just once per bar. AlgoPuzzle is a no-code strategy builder that exports MetaTrader 5 (.mq5), MetaTrader 4 (.mq4) and cTrader (.cs) files from rules you assemble from blocks.
Common questions
How do I open the Strategy Tester in MT5?
In MetaTrader 5, open the View menu and choose Strategy Tester, or press Ctrl+R. The tester panel opens at the bottom of the terminal, where the Settings tab lets you pick the Expert Advisor, symbol, timeframe, dates and modelling mode.
Which modelling mode should I use in the MT5 Strategy Tester?
Use Every tick based on real ticks when your broker provides tick history for the symbol, because it replays recorded prices instead of generated ones. Every tick is the fallback. Open prices only is fast but only suits an EA that acts exclusively at the open of a new bar, since it does not show what price did inside each bar.
Why doesn't my EA show up in the Strategy Tester?
The tester lists compiled Expert Advisors from the MQL5\Experts folder. If yours is missing, it usually has not been compiled yet, it failed to compile, or the file sits in the wrong folder. Open it in MetaEditor, press F7, make sure the Errors count is 0, then refresh the Navigator panel.
Is a profitable MT5 backtest enough to start trading live?
No. A backtest replays stored history, so it cannot show live slippage, requotes, connection problems or execution during fast markets. Run the same EA on a demo account for a while and check it behaves the way the backtest suggested before risking real money.