CFDs and forex are complex instruments and come with a high risk of losing money rapidly due to leverage. Risk disclosure

MT5 strategy tester: running and reading a backtest

This guide walks you through a backtest in MetaTrader 5, from choosing the modelling mode to reading the report without fooling yourself.

Extrade Pakistan editorial team ·

On this page
  1. What the strategy tester does
  2. Opening the tester and setting up a run
  3. Modelling modes
  4. Spread, commission and delays
  5. Reading the report
  6. Overfitting: the main trap
  7. MT4 strategy tester vs MT5
  8. Frequently asked questions

What the strategy tester does

The strategy tester is the part of MetaTrader 5 that runs an Expert Advisor (EA), meaning an automated trading program, on past price data. The result is a backtest: a simulation of how the EA's rules would have traded over a chosen period.

A backtest shows how the rules behaved on past data. It does not show how they will behave in future markets. Leveraged forex and CFD trading can lose money fast, and a good-looking backtest does not change that.

If you are new to EAs, read Expert Advisors and MQL4 and MQL5 before you start.

Past data (tuned)New datastart
Over-fitting: a strategy tuned to past data looks smooth on that data and often fails on data it has not seen. Test on a separate period and on a demo first. Illustrative example: made-up numbers for learning, not real prices or a broker's conditions.

Opening the tester and setting up a run

Open the tester from the View menu (Strategy Tester) or with Ctrl+R. Other key combinations are listed on Keyboard shortcuts. The tester panel has several tabs. The Settings tab is where you set up a run:

The Inputs tab holds the EA's parameters, such as lot size, stop loss and indicator periods. Set them, then press Start. If you tick Visual mode, a chart opens and replays the trades bar by bar. This is useful for checking that the EA does what you think it does.

Modelling modes

The modelling mode is the biggest factor in how realistic a test is.

Mode How prices are built When to use it
Every tick based on real ticks Uses recorded tick history, including real spreads Final checks, scalping, tight stops
Every tick Generates ticks from minute bars General testing when real ticks are missing
OHLC on minute bars Uses only the open, high, low and close of each minute bar Fast rough tests of bar-based EAs
Open prices only Uses only bar opening prices EAs that act only at a new bar
Math calculations No price data Pure calculations, not trading tests

The faster modes skip price movement inside the bar. An EA with tight stops or trailing stops can show fills that would never have happened. Use the coarse modes to filter ideas quickly. Then confirm on real ticks.

At the end of a run, check the history quality figure in the report. Low quality means gaps in the data, and the results are less reliable.

Spread, commission and delays

The spread is the gap between the bid and ask price, and it is a cost on every trade.

Commission and swap come from the symbol settings your terminal receives. Check that they match the account you plan to use. See Swap fees and Account types. Turn on Delays for strategies that are sensitive to execution speed. A strategy that only works with instant fills is fragile.

Reading the report

After the run, the Backtest tab shows the report and the Graph tab shows the balance and equity curves. Key lines:

Look at the shape of the equity curve, not just the final number. A curve that rises on a few large wins, or one that hides open losses, needs closer study. To size risk per trade, use the calculators and the guidance in Risk management.

Overfitting: the main trap

Overfitting means tuning an EA's inputs until they fit past data closely, including its random noise. Optimisation makes this easy: the tester can try thousands of parameter combinations and show you the one that happened to work best on that history.

Signs of overfitting:

Ways to reduce it:

MT4 strategy tester vs MT5

The MT4 strategy tester works on similar lines but has fewer options. It tests a single symbol per run, relies on generated ticks unless you import outside data, and has a simpler report. MT5 adds real-tick testing, multi-symbol EAs, delay simulation, forward testing and distributed optimisation agents. MT4 EAs do not run in MT5 without being rewritten. Note also that MT5 accounts can use hedging or netting, which changes how positions are counted. See Hedging vs netting and MT4 vs MT5.

Frequently asked questions

Why does my backtest show no trades?

Check the Journal tab. Common causes are missing history, wrong input values, a lot size the symbol does not allow, or a timeframe the EA was not built for. MetaTrader errors covers frequent messages.

Which modelling mode should I use?

Use "Every tick based on real ticks" for final checks. Faster modes are fine for early screening of EAs that act only at a new bar.

Can I set a fixed spread in MT5?

Not directly for a broker symbol. Real-tick mode uses the recorded spreads. For a custom spread, create a custom symbol.

Does a profitable backtest mean the EA will make money?

No. It shows past behaviour under simulated conditions. Live results can differ because of slippage, changing spreads and markets that behave differently. Leveraged trading can lose money fast.

Where are tester files stored?

In the terminal's data folder, which you can open from the File menu. The Tester subfolder holds the cache and agent logs.

Related pages