
Expert Advisors and Backtesting: An Honest MT5 Guide
President and co-founder, Elite Signals
Reviewed by Elie Faissal, CEO and co-founder of Elite Signals. Hypothetical examples only; no real trades or results are shown.
Short answer
An Expert Advisor (EA) is a program that runs inside MetaTrader and places, manages and closes trades by fixed rules. A backtest replays that program on past prices to see how the rules would have behaved. A backtest is useful for finding broken rules and understanding risk, but it is not a forecast. Read it honestly: check the data quality and modelling mode, include real costs, judge it on data it was not tuned on, look at the worst drawdown and losing streak before the total, and forward test on a demo before trusting it with money.
Automated trading has an obvious appeal: the rules run the same way every time, with no hesitation, no revenge trades and no moving the stop. That consistency is real. What automation cannot do is make a weak idea strong, and the tool most people use to judge an EA, the backtest, is very easy to read too kindly.
This guide covers what an EA is and how it runs, the MetaTrader 5 Strategy Tester and its settings, in-sample and out-of-sample testing, how overfitting happens, forward testing, and a checklist for reading a backtest report without fooling yourself. Examples are hypothetical and contain no performance figures. Trading leveraged products such as forex and gold CFDs carries a high risk of loss.
What an Expert Advisor is
In MetaTrader, an Expert Advisor is a program attached to a chart that reacts to price updates and can send orders to your broker by itself. MetaTrader's own help splits automated programs into two kinds: trading robots (Expert Advisors), which are "designed for performing trading operations", and indicators, which analyse prices and draw on the chart. Only one EA can run on each chart, and automated trading has to be switched on before it can place orders [1].

Every EA, simple or complex, does four jobs:
- Entry rules: the exact conditions that open a trade, such as a level, a time window, a pattern or an indicator reading.
- Risk rules: where the stop goes and how big the position is, ideally set the moment the order opens.
- Management rules: moving the stop, partial exits, time-based exits.
- Safety rules: what it does on wide spreads, lost connections, news windows or a daily loss limit.
The fourth group is the one buyers check least. Ask what the EA does in the hour you are not watching: a spread spike, a broker reconnect, or a gap over the weekend.
Strategies to be careful with
Some EAs look smooth for a long time because of how they handle losers rather than how they find winners. Grid and martingale designs add to losing positions, often at larger size, so the account curve climbs steadily until one move goes far enough to cause a large loss. Averaging down, removing the stop, or increasing size after a loss are rules to look for in the description and the code before anything else. An EA with a fixed stop on every trade can still lose, but its worst case is visible in advance.
How the MT5 Strategy Tester works
MetaTrader 5 includes a Strategy Tester that runs an EA on historical data as if the market were live. The main settings decide how realistic that replay is [2]:
| Setting | What it controls | What to choose and why |
|---|---|---|
| Symbol and timeframe | The chart the EA runs on | The same symbol and timeframe you plan to trade, on your broker's data |
| Date range | The history used | Several years covering trending, ranging and volatile periods |
| Modelling (tick generation) | How prices move inside each bar | "Every tick based on real ticks" or "Every tick" for final tests; faster modes only for rough checks |
| Deposit and leverage | Starting balance and margin | The balance and leverage you would really use |
| Delays | Time between the order and the fill | A realistic or random delay instead of "zero latency" |
| Forward | Splits the period into a back test and a forward test | A split such as 1/3 or 1/4 to keep the latest data unseen |
The modelling mode deserves the most attention. MT5's help explains that the tester can generate every tick inside each bar, only the four prices of each one-minute bar, or only the opening price of each bar, and states plainly that "the mode of every tick generation is the most accurate, but the slowest one" [3]. An EA with tight stops, or one that trades the first minutes of a session, can look very different under "Open prices only" than under real ticks, because the tester cannot know which came first inside a bar: the high or the low. Real ticks also carry the real spread: on real tick data "a spread may change within a minute bar", while generated ticks use one fixed spread for that bar [3].
Costs belong in the test
Spread, commission and swap are part of every real trade. A test on a fixed, tight spread can make a short-term strategy look far better than it would be on a live account, where spreads widen at the open, at the close and around news. Use your broker's real commission, test at a wider spread as a stress check, and treat any strategy whose edge disappears when the spread doubles as fragile.
In-sample and out-of-sample testing
Every time you change a setting after looking at a result, the data you looked at is no longer a fair test. That data is in-sample: it helped build the strategy. Data the strategy has never been tuned on is out-of-sample, and it is the only kind that says something about the future.

A simple discipline is to split the history before you start:
- Build on the first part. Develop the rules and choose settings on, say, the first 60% to 70% of the period.
- Test once on the rest. Run the finished rules, unchanged, on the remaining 30% to 40%. Look at it once.
- Accept the answer. If it falls apart, the idea did not hold. Going back to tweak until the out-of-sample part looks good turns it into in-sample data.
MT5 builds this in. Its Forward setting splits the chosen period, and "always the second (latest) part of the total period is taken for the forward testing", so optimisation runs on the first part and results are then checked on the later part [2].
Walk-forward testing
Walk-forward testing repeats that split in steps: tune on one window, test on the next, move both forward, and repeat. It shows whether settings chosen on the past keep working on the period right after, which is closer to how an EA is used in practice. If the settings that win each window keep changing wildly, that is a sign the strategy is fitting noise.
Overfitting: how a backtest lies
Overfitting happens when a strategy is tuned so closely to past data that it captures the noise in that data rather than a lasting pattern. It is easy to do by accident. The MT5 optimiser can run every combination of the settings you allow, or use a genetic algorithm that searches very large sets of combinations in hours rather than years [4]. Search enough combinations and some will look excellent on the past by chance alone.
Researchers have measured how fast this goes wrong. Bailey, Borwein, López de Prado and Zhu showed that high backtest performance "is easily achievable after backtesting a relatively small number of alternative strategy configurations", and that the more configurations are tried, the more likely the backtest is overfit [5]. Harvey and Liu make a related point: when many strategies are tried, a backtest needs a much higher bar before it counts as evidence [6].
Warning signs of an overfit EA:
- Many settings with very specific values (a 37-period average, a 13:47 start time) where nearby values give poor results.
- A curve that is near-perfect in-sample and flat or falling out-of-sample.
- Few trades in the test, so a handful of lucky ones drive the whole result.
- Rules added to avoid single bad periods in the past ("do not trade on the third Friday").
- Results that depend on one market and one timeframe and break on any neighbour.
A robust strategy usually has few settings, works across a range of nearby values, and has a simple reason for existing that you can write in one sentence. Our post on AI in day trading covers the same trap for AI-tuned settings.
Forward testing on a demo account
Forward testing means running the EA in real time, on a demo account or a very small live one, before trusting it with meaningful money. It is the first test the strategy cannot have seen, and it is where real-world problems show up: slippage, spreads at odd hours, missed bars when the platform disconnects, and broker rules the tester did not model.
A few practical points:
- Run it long enough to see a reasonable number of trades and at least one change in market conditions. A strategy that trades a few times a week needs months, not days.
- Compare like with like. Run the backtest over the same weeks as the demo and compare trade by trade. Big differences in entries or fills point to modelling or cost problems.
- Keep the platform running. An EA only works while MetaTrader is open and connected. Decide where it runs, and what happens if that computer restarts.
- Change nothing mid-test. A setting changed halfway through starts a new test.
Demo results are still not live results. Fills on a demo can be kinder than on a live account, so treat the demo as a check on behaviour, not a promise of outcomes.
How to read a backtest report honestly
The MT5 testing report lists dozens of figures, from net result and profit factor to drawdown, consecutive losses and history quality [7]. The order you read them in matters. Start with the figures that tell you whether the test can be trusted, then the ones that tell you what it would feel like, and only then the total.
| Read | Figure | The question it answers |
|---|---|---|
| 1 | History quality, modelling mode, ticks | Is the data good enough to trust the rest? |
| 2 | Spread, commission and delay settings | Are costs close to a live account? |
| 3 | Total trades | Is the sample large enough to mean anything? |
| 4 | Maximal and relative drawdown (balance and equity) | What is the worst fall from a high, and could I sit through it? |
| 5 | Maximum consecutive losses | How long is the worst losing streak? |
| 6 | Largest loss trade vs average loss | Is there a hidden tail, such as one very large loss? |
| 7 | Out-of-sample or forward section | Does it hold on data it was not tuned on? |
| 8 | Net result, profit factor, expected payoff | Only now: what did the rules return on this history? |

Equity drawdown matters more than balance drawdown for strategies that hold losing trades open, because balance only changes when a trade closes. An EA can show a mild balance curve while its open losses went much deeper. If your account has a daily or maximum loss limit, such as in a prop firm challenge, the equity figure is the one that would have counted.
Then size the result to your own account. A drawdown in a backtest run at one size becomes a different dollar loss at yours; our position size calculator helps translate a per-trade risk into lots. And keep the expectancy math in mind: a strategy can win less than half its trades and still have a positive edge, or win most of them and still lose. Our guide to win rate and reward to risk explains why.
What regulators say about simulated results
U.S. rules for commodity trading advisors require a warning with hypothetical results: they "have certain inherent limitations", "do not represent actual trading", and simulated programs "are designed with the benefit of hindsight" [8]. The CFTC has also warned about automated trading schemes that promise "unreasonably high or guaranteed returns", including one that created fake customer balances using MetaTrader demo accounts [9]. A screenshot of a backtest, or of a demo account, is not a track record.
When a backtest tells you very little
Some strategies are hard to backtest well, and it is better to know that up front:
- News-driven strategies, because spreads and fills around releases are rarely modelled accurately. See our FOMC trading guide for why those minutes behave differently.
- Scalping with very tight stops, where a fraction of a pip of slippage or spread changes the outcome of most trades.
- Strategies that depend on the market regime, such as trend systems tested only on a trending stretch. Our guide to trading choppy markets covers how conditions change.
- Short histories, where the test covers one type of market and a few dozen trades.
In those cases, a long forward test at small size tells you more than any amount of optimisation.
Common questions
What is an Expert Advisor in MetaTrader?
An Expert Advisor is a program that runs on a MetaTrader chart and can open, manage and close trades by itself according to fixed rules. It is different from an indicator, which analyses prices and draws on the chart but does not trade.
Which modelling mode should I use in the MT5 Strategy Tester?
For a final test, use "Every tick based on real ticks" if your broker provides tick history, or "Every tick" if not. Faster modes such as "1 minute OHLC" and "Open prices only" are fine for quick checks of rules that act once per bar, but they can misstate results for strategies with tight stops or fast entries.
What is the difference between in-sample and out-of-sample data?
In-sample data is the history used to build and tune the strategy. Out-of-sample data is history the strategy has never been tuned on. Only out-of-sample results give a fair idea of how the rules behave on new data, and only if you look at them once and do not tune again.
How do I know if my EA is overfit?
Common signs are many settings with very specific values, a strong in-sample curve that goes flat out-of-sample, results that collapse when a setting is nudged slightly, and a small number of trades. A robust strategy keeps working across nearby settings and has a simple reason to exist.
Why do backtest results differ from live trading?
The usual causes are modelling (the tester guessing price moves inside bars), costs (spreads, commission and swap set too low), execution (slippage and delays), and overfitting. A forward test on a demo account, compared trade by trade with a backtest over the same weeks, shows which one is responsible.
How long should I forward test an EA?
Long enough to see a meaningful number of trades and at least one change in market conditions. For a strategy that trades a few times a week, that usually means several months. Change nothing during the test.
Can I trust a vendor's backtest?
Treat it as a description of the rules, not as evidence of future results. Ask for the modelling mode, cost settings, test period and number of trades, run the test yourself on your broker's data where you can, and forward test before trading meaningful size.
Sources
- MetaQuotes, MetaTrader 5 Help, Trading robots and technical indicators.
- MetaQuotes, MetaTrader 5 Help, Strategy testing.
- MetaQuotes, MetaTrader 5 Help, Tick generation modes.
- MetaQuotes, MetaTrader 5 Help, Optimization types.
- Bailey, D. H., Borwein, J. M., López de Prado, M. and Zhu, Q. J., Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance, 2014.
- Harvey, C. R. and Liu, Y., Backtesting, 2015.
- MetaQuotes, MetaTrader 5 Help, Testing report.
- U.S. Code of Federal Regulations, 17 CFR § 4.41, Advertising by commodity pool operators, commodity trading advisors, and the principals thereof.
- U.S. Commodity Futures Trading Commission (CFTC), Customer Advisory: SI Won't Turn Trading Bots into Money Machines.
