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.
Ready to try it on a real or demo account?
Partner link · trading carries a high risk of loss
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:
- Expert: pick the EA from the list. It must be compiled and placed in the Experts folder of the terminal's data folder.
- Symbol and timeframe: choose the instrument and the chart period the EA works on. Check the symbol's contract specifications so you know the contract size, tick value and trading hours.
- Date: set the start and end of the test period.
- Forward: optionally reserve the later part of the period for an out-of-sample check (explained below).
- Delays: simulate execution latency instead of instant fills.
- Modelling: choose how prices are generated (next section).
- Deposit and leverage: set the starting balance, account currency and leverage.
- Optimization: leave it disabled for a single backtest.
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.
- With real ticks, the tester uses the spread recorded in the tick history.
- With generated ticks, it takes spread from the bar history. If that is missing, it uses the current spread, which can look better or worse than reality.
- Unlike the MT4 strategy tester, which has a spread field, MT5 has no simple fixed-spread box for a broker symbol. To test a deliberately wider spread, traders usually create a custom symbol with its own settings.
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:
- Total net profit: gross profit minus gross loss over the period.
- Profit factor: gross profit divided by gross loss. A higher value means winners outweighed losers by more. A value near break-even leaves little room for real costs.
- Expected payoff: the average result per trade. If it is small compared with the spread, slippage can wipe it out.
- Balance and equity drawdown: the largest fall from a peak, shown as an amount and as a share of the account. Equity drawdown includes open trades, so it is the more honest figure. Ask yourself whether you could sit through that drop with real money.
- Recovery factor: net profit relative to maximum drawdown.
- Sharpe ratio: return relative to how much the results varied.
- Total trades: a handful of trades says little. More trades across different market conditions say more.
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:
- Results collapse when a parameter changes slightly.
- Many inputs and filters, but few trades.
- Strong results on one symbol or period only.
- A smooth curve in the test, but poor results on any new data.
Ways to reduce it:
- Use the Forward setting. The tester optimises on the earlier part of the period and checks on the later part it did not see.
- Prefer parameter ranges where results stay steady, not a single sharp peak.
- Test on other periods and related symbols.
- Run the EA on a demo account before any real money. See the MT5 demo account.
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.
