Winservers.NET

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.

StepWhat to doWhy it matters
1Open the Strategy Tester: menu View, Strategy Tester. Or right-click an Expert Advisor in the Navigator and choose TestThe second way selects the EA for you
2Choose the Expert AdvisorThe tester runs compiled EAs from your terminal
3Choose the symbol and timeframeThis is the chart the EA would be attached to. Multi-symbol EAs get the other symbols automatically if they are enabled in Market Watch
4Set the date rangeThe start date is included, the end date is not. The tester also loads some earlier history so indicators have data
5Choose the tick generation modeIt decides accuracy and speed. See the table below
6Set deposit, currency and leverageLeverage changes the margin reserved for positions
7Choose the execution delayNo delay shows ideal conditions. A fixed or random delay is closer to real trading
8Check the inputs on the Inputs tabUse the values you plan to trade with. You can save them as a set file
9Press StartA single test is one run with fixed parameters
10Read the Backtest and Graph tabsLook 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.

ModeWhat the tester doesUse it for
Every tickSimulates all ticks from minute data. The most accurate generated mode and the slowestScalping, intraday systems, anything with stops inside a bar
Every tick based on real ticksUses real ticks collected by your broker, no simulation. The first download can take a long timeThe final check before going live
1 minute OHLCEmulates only the open, high, low and close of each minute barFaster runs for systems that do not depend on movement inside a minute
Open prices onlyUses only bar open prices. Quick but roughFirst screening of EAs that act once per bar
Math calculationsNo history and no ticks. Only OnInit, OnTester and OnDeinit are calledPure 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:

SettingOptionsNote
Optimization modeSlow complete algorithm, Fast genetic based algorithm, All symbols selected in Market WatchComplete checks every combination. Genetic searches part of the space
Optimization criterionBuilt-in criteria such as Sharpe ratio and the complex criterion, or your own valueUsed by the genetic algorithm to pick the best runs
InputsStart, step and stop for each parameter you tickThe tester shows the total number of combinations under the list
ForwardNo, 1/2, 1/3, 1/4 or a custom start dateAlways 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 testingA sensible machineTypical choice
A few single backtests4 to 8 cores, 16 GB RAM, SSDYour own PC or a Windows VPS
Regular optimizations on one or two symbols8 to 16 cores, 32 to 64 GB RAM, NVMeA dedicated server
Long tick optimizations on many symbols16 or more cores, 64 GB RAM or more, NVMeA 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:

PlanCPURAMStoragePrice per monthOne-time setup
RYZEN-3600AMD Ryzen 5 3600, 6 cores / 12 threads64 GB DDR42x 512 GB NVMe SSDEUR 99No setup fee
INTEL-I5-13500 (limited availability)Intel Core i5-13500, 14 cores / 20 threads64 GB DDR42x 512 GB NVMe SSDEUR 99No setup fee
RYZEN-8700GEAMD Ryzen 7 PRO 8700GE, 8 cores / 16 threads64 GB DDR52x 512 GB NVMe SSDEUR 139EUR 49
CORE-ULTRA-265Intel Core Ultra 7 265, 20 cores / 20 threads64 GB DDR52x 1 TB NVMe SSDEUR 189EUR 74
RYZEN-7950X3DAMD Ryzen 9 7950X3D, 16 cores / 32 threads128 GB DDR52x 1.92 TB NVMe SSD DatacenterEUR 299EUR 129
XEON-6731PIntel Xeon Gold 6731P, 32 cores / 64 threads128 GB DDR5 ECC reg.2x 1.92 TB NVMe SSD DatacenterEUR 599EUR 279
EPYC-9454PAMD EPYC 9454P, 48 cores / 96 threads128 GB DDR5 ECC reg.2x 3.84 TB NVMe SSD DatacenterEUR 654EUR 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.

Ask which server fits my backtests

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.

Ask in WhatsApp or Telegram

K.S.M. Trade Sp. z.o.o. | NIP/VAT PL5273128546 | REGON 52957272900000 | Warsaw, Poland