On this pageSet up a run
The Strategy Tester in MetaTrader 4 replays price history through an Expert Advisor and records every trade it would have made. It is the fastest way to see how an EA behaves, what it does in a trend or a range, how it sizes positions, where it fails. It also produces neat numbers that look more certain than they are. This guide covers how to set up a test, how the tester builds its prices, how to read the report and where its picture of the past stops matching the live market.
Set up a run
Open the tester with View > Strategy Tester or Ctrl+R. The panel at the bottom of the terminal holds every setting:
| Setting | What it does | What to watch |
|---|---|---|
| Expert Advisor | Lists compiled EAs from MQL4\Experts |
Compile the source first if only the .mq4 exists |
| Symbol and Period | The instrument and timeframe replayed | Use the ones the EA is designed for |
| Model | How ticks are generated (next section) | The most important choice in the panel |
| Use date | Limits the test to a date range | Use it to keep part of the history aside |
| Visual mode | Plays the test on a chart | Slower, but shows what the EA actually does |
| Spread | Current spread or a fixed value | Set it yourself rather than taking whatever "current" is |
| Optimization | Tests many input combinations | Leave off for a first run |
Expert properties opens three more tabs. Testing sets the initial deposit and its currency, which directions are allowed and whether optimization uses a genetic algorithm. Inputs holds the EA's parameters: a single value for a plain test, or start, step and stop values for optimization. Optimization limits the number of passes.
How the tester builds its prices
MT4 does not replay your broker's tick history. It builds ticks from the bars stored in the terminal, using one of three models:
| Model | How it works | Fits | Caution |
|---|---|---|---|
| Every tick | Builds ticks from all smaller timeframes available, down to one minute | Most EAs, especially those that act within a bar | Slowest; still modeled, not real |
| Control points | Uses the nearest smaller timeframe for a rough path inside each bar | Quick first checks | Too coarse for stops and targets inside a bar |
| Open prices only | Runs once per bar, on its opening tick | EAs that only act on completed bars | Misleading for anything that reacts within a bar |
Even in Every tick mode, the order in which a bar reached its high and its low is reconstructed, not recorded. An EA with tight stops and targets inside one-minute bars is exactly the kind whose result depends on that guess.
History decides the result
The tester can only use the history the terminal holds. Two settings and one tool control it:
- Max bars in history under Tools > Options > Charts caps how many bars the terminal keeps on disk, and so how far back a test can go.
- History Center (F2) shows the stored data per symbol and timeframe and can download more. Downloaded data can come from MetaQuotes' history servers rather than your broker, so its prices may differ slightly from your broker's feed.
- Modeling quality in the report shows how complete the smaller-timeframe data was. Its colored band marks each stretch of the test: gray where data was not used, red where smaller-timeframe data was missing, green where ticks were modeled, brighter for better coverage. A test in Open prices only mode shows an entirely red band, by design.
Modeling quality measures data coverage, not realism. A high figure means the tester had the bars it needed to build ticks; it does not mean the ticks match what traded.
Spread and execution
With Spread set to current, the tester takes the spread at the moment you press Start and applies it to the whole run. Start a test at a quiet hour or on a weekend and that figure may be far from what you see when you trade. Enter a fixed value, in points, that reflects your trading hours, and run the test again with a wider one to see how sensitive the EA is to costs.
Orders in the tester fill at the modeled price, without the delay, requotes, rejections and slippage of a live server. For an EA that aims at small moves, that difference can matter more than any setting in the panel.
Read the report
After a run, the Report tab sums it up, the Results tab lists every trade, the Graph tab draws the balance curve and the Journal tab logs the run, errors included. Right-click the report to save it as a file.
| Figure | What it measures |
|---|---|
| Bars in test, Ticks modeled | How much history and how many ticks the run used |
| Modeling quality | Coverage of the smaller-timeframe data used to build ticks |
| Total net profit | The financial result of all trades |
| Gross profit, Gross loss | The sum of winning trades and of losing trades |
| Profit factor | Gross profit divided by gross loss |
| Expected payoff | The average result per trade |
| Absolute drawdown | The largest fall of the balance below the initial deposit |
| Maximal drawdown | The largest fall from a peak to the following low, in money and percent |
| Relative drawdown | The same idea expressed as the largest percentage fall |
Read the drawdown figures as a record of this history only. The next drawdown has no obligation to stay inside the largest one in the test. Then read the Results tab trade by trade: average trade size against the spread you set, clusters of losses, and whether position sizes grow after losing trades, which a balance curve can hide until it does not.
Optimize without fooling yourself
Optimization runs the EA with every combination of the inputs you mark, or a sample of them with the genetic algorithm, and lists the passes. The best pass is the one that fitted this history best, which is not the same as the one most likely to work later.
A few habits keep the exercise honest:
- Keep history aside. Use Use date to optimize on an earlier period only, then run the chosen settings once on a later period you never optimized on.
- Look at neighbors. A good pass surrounded by poor ones is more likely fitted to noise than a broad region where nearby values give similar results.
- Count the tries. The more combinations you test, the more likely the best one owes its rank to chance.
What the tester cannot show
- More than one symbol at a time. An EA that trades several symbols cannot be tested as a whole in MT4.
- Real ticks, real spreads and real fills. Prices are modeled and costs are simplified.
- Your broker's execution. Requotes, rejections, slippage and server delays only appear live.
- The future. A test describes one stretch of history.
MetaTrader 5's tester narrows some of these gaps, with real-tick testing, multi-symbol tests and simulated execution delays. In MT4, the next step after a backtest is a forward test on a demo account, comparing its logs with the test: same signals, similar fills, similar costs.
Where to run long tests
An optimization can keep a terminal busy for hours, so run it in a separate installation rather than in the terminal that trades. A separate server billed by the hour, such as a CloudSat High Frequency VPS, can run long tests on fast cores and be deleted when they finish.
FAQ
What modeling quality is good enough?
The figure only tells you how complete the bar data was. A high value is necessary for a meaningful Every tick test, but it does not make modeled ticks real, so treat it as a minimum condition rather than a seal of approval.
Why do two brokers give different results for the same EA?
Their history differs: price feeds, spreads, contract sizes and server time zones, which change where daily bars start and end. Test on the data of the broker you will trade with.
Should I trust a seller's backtest screenshot?
Only as far as you can reproduce it. Ask for the settings file and the period, run it yourself on your broker's data with your own spread, and compare.
Does a good backtest mean the EA will make money?
No. It shows that the rules would have produced that result on that history, under the tester's simplifications. Live results depend on markets that have not happened yet.
Trading involves risk of loss. Nothing in this article is financial advice.
Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.




