MT5 Strategy Tester · Guide
How to Backtest in MetaTrader 5: Strategy Tester Step by Step
A practical walk through the MetaTrader 5 Strategy Tester: how to run a first backtest, which tick mode to trust, how to optimize without fitting the past, and when the hardware starts to matter.
Quick answer: open the Strategy Tester from the View menu, choose your Expert Advisor, symbol, timeframe and dates, pick a tick mode (Every tick for accuracy), set deposit and leverage, and press Start. Read the Backtest and Graph tabs. For optimization, tick the inputs to vary and switch on a Forward period so the best settings are checked on data they were not fitted to.
Step by step
How to run your first backtest in MT5
A test is a single run of an Expert Advisor with fixed parameters on historical prices. The steps follow the official MetaTrader 5 documentation.
| Step | What to do | Why it matters |
|---|---|---|
| 1 | Open the Strategy Tester: menu View, Strategy Tester. Or right-click an Expert Advisor in the Navigator and choose Test | The second way selects the EA for you |
| 2 | Choose the Expert Advisor | The tester runs compiled EAs from your terminal |
| 3 | Choose the symbol and timeframe | This is the chart the EA would be attached to. Multi-symbol EAs get the other symbols automatically if they are enabled in Market Watch |
| 4 | Set the date range | The start date is included, the end date is not. The tester also loads some earlier history so indicators have data |
| 5 | Choose the tick generation mode | It decides accuracy and speed. See the table below |
| 6 | Set deposit, currency and leverage | Leverage changes the margin reserved for positions |
| 7 | Choose the execution delay | No delay shows ideal conditions. A fixed or random delay is closer to real trading |
| 8 | Check the inputs on the Inputs tab | Use the values you plan to trade with. You can save them as a set file |
| 9 | Press Start | A single test is one run with fixed parameters |
| 10 | Read the Backtest and Graph tabs | Look at drawdown and the shape of the balance curve, not only at total profit |
Before a multi-symbol test: open Market Watch, choose Symbols and enable every instrument the EA trades. Only symbols selected in Market Watch are available to the tester.
Accuracy
Which tick mode to choose
The tick generation mode is the setting that changes results the most. MT5 offers five, described in the tick generation section of the help.
| Mode | What the tester does | Use it for |
|---|---|---|
| Every tick | Simulates all ticks from minute data. The most accurate generated mode and the slowest | Scalping, intraday systems, anything with stops inside a bar |
| Every tick based on real ticks | Uses real ticks collected by your broker, no simulation. The first download can take a long time | The final check before going live |
| 1 minute OHLC | Emulates only the open, high, low and close of each minute bar | Faster runs for systems that do not depend on movement inside a minute |
| Open prices only | Uses only bar open prices. Quick but rough | First screening of EAs that act once per bar |
| Math calculations | No history and no ticks. Only OnInit, OnTester and OnDeinit are called | Pure calculations, not trading tests |
Generated ticks or real ticks
In Every tick mode the tester builds ticks from minute data and uses one fixed spread for each minute bar. With real ticks the spread can change inside the bar, as it does in the market. If a minute has no real tick data, the tester falls back to generated ticks for that minute. For strategies that live on small moves, test on real ticks before you trust the result.
A workable routine
- Screen ideas on 1 minute OHLC or Open prices only.
- Retest the survivors on Every tick.
- Confirm the final version on real ticks.
Make the test honest
- Set commissions and swaps to match your broker.
- Use an execution delay, not the ideal No delay mode.
- Test on the account currency and leverage you will trade.
More on data quality: backtesting accuracy with custom symbols and tick data.
Optimization
How to optimize an EA
Optimization runs the same EA many times with different input values to find settings that work. On the Inputs tab, tick the parameters to vary and set a start value, a step and a stop value for each. Settings from the optimization section of the help:
| Setting | Options | Note |
|---|---|---|
| Optimization mode | Slow complete algorithm, Fast genetic based algorithm, All symbols selected in Market Watch | Complete checks every combination. Genetic searches part of the space |
| Optimization criterion | Built-in criteria such as Sharpe ratio and the complex criterion, or your own value | Used by the genetic algorithm to pick the best runs |
| Inputs | Start, step and stop for each parameter you tick | The tester shows the total number of combinations under the list |
| Forward | No, 1/2, 1/3, 1/4 or a custom start date | Always the latest part of the period |
If you stop an optimization with the Stop button, the finished runs are kept and the process continues from the last one when you start it again. During genetic optimization, intermediate results are saved after every generation.
A full search grows fast: three parameters with 20 values each are 8,000 runs. That is where the genetic algorithm and more CPU cores start to pay off. See optimizing EA parameters with genetic algorithms.
Against overfitting
Check the result on a forward period
An optimizer always finds parameters that look good on the data it searched. The question is whether they work on data it did not see. MT5 has a built-in check for this: the Forward option.
How it works
The period is split in two. The EA is optimized on the first part. The best runs are then tested on the second, later part.
How many runs go forward
10% of the runs after a complete search, 25% after a genetic one. Results appear on a separate Forward tab.
What to look for
Settings that stay reasonable in both parts. A result that is excellent in the first part and poor in the second was fitted to the past.
Walk-forward and Monte Carlo
The Forward option is one out-of-sample check. A rolling walk-forward repeats it: optimize, test the next segment, move the window, repeat. In the standard tester this means several optimizations with shifted dates, run by hand or with scripts and add-on tools. Monte Carlo analysis, which reshuffles or varies the trades to see how fragile the result is, is also done outside the standard tester. We cover both in forward testing and walk-forward optimization and the walk-forward server workflow.
Keep it simple. Optimize few parameters, use wide sensible ranges and prefer areas where results are stable over one best value. No test predicts live results. Winservers.NET rents servers and does not give trading advice.
Speed
What makes backtests fast or slow
The Strategy Tester is multi-threaded. According to the MetaTrader 5 documentation, it creates one local agent for each logical core of your processor, and each optimization pass runs as a separate process on a free agent.
A single test
One run uses one agent. More cores do not help. A faster core does.
An optimization
Passes are spread over all agents. Twice the cores means roughly twice the passes at once, if RAM keeps up.
Remote agents
You can connect agents on other computers. They work only on 64-bit systems, and DLL calls are not allowed on remote agents.
MQL5 Cloud Network
A paid network of agents around the world that the tester can use for large optimizations.
A rough hardware guide
| Your testing | A sensible machine | Typical choice |
|---|---|---|
| A few single backtests | 4 to 8 cores, 16 GB RAM, SSD | Your own PC or a Windows VPS |
| Regular optimizations on one or two symbols | 8 to 16 cores, 32 to 64 GB RAM, NVMe | A dedicated server |
| Long tick optimizations on many symbols | 16 or more cores, 64 GB RAM or more, NVMe | A dedicated server, then remote agents |
These are planning ranges, not promises: the real need depends on your EA, the tick mode and the number of symbols. Detailed guides: how many CPU cores, how much RAM, Ryzen 9 7950X or Intel i9-13900K, why optimization slows down and how to add remote agents.
Servers
When your PC is no longer enough
If optimizations keep your computer busy for hours or days, move the tester to a machine that works around the clock. Light tests run on a Windows VPS. Regular optimizations belong on a dedicated server, where every core is yours. Current dedicated plans, prices per month:
| Plan | CPU | RAM | Storage | Price per month | One-time setup |
|---|---|---|---|---|---|
| RYZEN-3600 | AMD Ryzen 5 3600, 6 cores / 12 threads | 64 GB DDR4 | 2x 512 GB NVMe SSD | EUR 99 | No setup fee |
| INTEL-I5-13500 (limited availability) | Intel Core i5-13500, 14 cores / 20 threads | 64 GB DDR4 | 2x 512 GB NVMe SSD | EUR 99 | No setup fee |
| RYZEN-8700GE | AMD Ryzen 7 PRO 8700GE, 8 cores / 16 threads | 64 GB DDR5 | 2x 512 GB NVMe SSD | EUR 139 | EUR 49 |
| CORE-ULTRA-265 | Intel Core Ultra 7 265, 20 cores / 20 threads | 64 GB DDR5 | 2x 1 TB NVMe SSD | EUR 189 | EUR 74 |
| RYZEN-7950X3D | AMD Ryzen 9 7950X3D, 16 cores / 32 threads | 128 GB DDR5 | 2x 1.92 TB NVMe SSD Datacenter | EUR 299 | EUR 129 |
| XEON-6731P | Intel Xeon Gold 6731P, 32 cores / 64 threads | 128 GB DDR5 ECC reg. | 2x 1.92 TB NVMe SSD Datacenter | EUR 599 | EUR 279 |
| EPYC-9454P | AMD EPYC 9454P, 48 cores / 96 threads | 128 GB DDR5 ECC reg. | 2x 3.84 TB NVMe SSD Datacenter | EUR 654 | EUR 304 |
Servers are in Frankfurt, Germany, with Windows and Remote Desktop, rented monthly. See the MT5 optimization server page, and the MT5 backtest farm if you want several servers working as remote agents for your own terminal. When the strategy is ready, run it live on a separate MT5 VPS, so tests never compete with live trading.
FAQ
Frequently asked questions
What is backtesting in MetaTrader 5?
Backtesting in MT5 is running an Expert Advisor on historical market data in the Strategy Tester to see how it would have behaved. The tester simulates order execution and calculates balance, equity and statistics such as profit factor and drawdown.
How do I start a backtest in MT5 step by step?
Open the Strategy Tester from the View menu, or right-click the Expert Advisor in the Navigator and choose Test. Select the symbol and timeframe, the date range and the tick generation mode, set the deposit and leverage, check the inputs and press Start. Then read the Backtest and Graph tabs.
Is MT5 backtesting free?
Yes. The Strategy Tester is part of the MetaTrader 5 terminal. You need the terminal, an account with a broker for history data, and the EA you want to test.
Which tick mode should I use: Every tick, 1 minute OHLC or Open prices only?
For scalping, intraday systems and any logic that depends on movement inside a bar, use Every tick, and Every tick based on real ticks for the final check. 1 minute OHLC and Open prices only are faster and suit systems that act on bar open or close, but they are less precise for stops inside a bar.
Do I need real tick data for reliable MT5 backtests?
For scalpers, grid systems and short-term intraday strategies, real ticks are strongly recommended. With real ticks the spread can change inside a minute bar, while generated ticks use one fixed spread per bar. For higher-timeframe systems, generated ticks are often acceptable.
What is strategy optimization in MT5?
Optimization runs the same EA many times with different input values. MT5 offers a slow complete algorithm that tests every combination, a fast genetic algorithm that searches part of the space, and a mode that runs one set of inputs on all symbols in Market Watch.
What is the Forward option in the MT5 Strategy Tester?
It splits the chosen period in two. The EA is optimized on the first part, then the best runs are tested on the second, later part: 10% of the runs after a complete search and 25% after a genetic one. It shows whether good parameters still work on data they were not fitted to.
Does MT5 have walk-forward and Monte Carlo tests?
The standard tester has the Forward option, which is one out-of-sample check. A rolling walk-forward, where you optimize, test the next segment and repeat, is done by running several optimizations with shifted dates, by hand or with scripts and add-on tools. Monte Carlo analysis of the trade list is also done outside the standard tester.
How do I avoid overfitting when optimizing an EA?
Optimize few parameters, use wide sensible ranges, always keep a forward period, and prefer parameter areas where results are stable over a single best value. A strategy that only works with one exact set of numbers is usually fitted to the past.
Why do my backtest results differ from live trading?
Typical reasons are different spreads and commissions, lower-quality history, slippage and execution delays in live trading, broker rules such as stop levels, and overfitting. Use real ticks, realistic costs and an execution delay to bring the test closer to reality.
How many years of data should I use?
It depends on the strategy. Many traders use at least 2 to 5 years for intraday systems and 10 years or more for swing systems when good data exists. The period should include different market conditions, not one trend.
How do I save and reuse tester settings?
On the Inputs tab use the context menu to save parameters as a set file and load it later. The tester can also save its whole configuration to an ini file, and you can copy the current settings with Ctrl+C and paste them back with Ctrl+V.
How do I run a multi-symbol backtest?
Enable the needed symbols in Market Watch and run the EA on one main chart in the tester. The tester loads the history of every symbol the EA uses automatically.
Does MT5 use the GPU for backtesting?
No. The Strategy Tester computes on the CPU. For faster tests you need more and faster CPU cores, enough RAM and fast storage.
How many cores does the MT5 Strategy Tester use?
All of them. MT5 creates one local agent per logical core and gives each optimization pass to a free agent. A single backtest uses one agent.
When should I move backtesting from my PC to a server?
When optimizations block your PC for many hours, when you test many EAs and symbols, or when the queue grows faster than you can run it. A server works around the clock and does not slow down the computer you work on.
Waiting days for an optimization?
Tell us your EA, symbols, history depth and roughly how many passes you run. We will suggest a server or a farm setup for it.