How to Backtest an EA Properly
Key takeaways
- Modelling quality decides whether the test is realistic. Real tick data exists only on MetaTrader 5 and only for the period your broker stored, and every other mode is interpolated.
- Spread and commission must be set to what you actually pay, because a test at an unrealistic spread flatters every strategy.
- A test that excludes a market regime is a test of the regime it included, not of the strategy.
- Optimisation finds the settings that fit the past best, which is a different thing from settings that work next.
- Read maximum drawdown and trade count before profit, because profit without those two is not a result.
- A backtest cannot show you slippage, server downtime, or what you do under pressure, which is why demo running comes after it.
What a backtest can and cannot tell you
A backtest replays historical price data and shows what a set of rules would have done. That is genuinely useful for one purpose: finding out whether the logic is coherent and survivable, rather than whether it will make money.
What it cannot tell you is what happens next. Past prices are a single realised path out of many that were possible, and a strategy tuned to that path is tuned to something that will not repeat. The gap between a clean backtest and a live account is the subject of EA backtest against live results.
So run it to disqualify, not to confirm. A strategy that fails a careful backtest is almost certainly not worth live money. One that passes has earned a demo account, not a funded one.
The setup that makes a test meaningful
Four settings, and all four are commonly left wrong in the tests people post.
Modelling quality. MetaTrader 5 offers Every tick based on real ticks, Every tick, 1 minute OHLC, Open prices only and Math calculations. Real ticks is the only mode that is not interpolated, and only over the period your broker's tick history actually covers. MetaTrader 4 has no real tick mode at all, so an MT4 test of an intraday strategy is modelled price by definition.
Spread. Set it to what your broker actually charges, not to the tester default. A test run at one point of spread on an instrument that costs three will show a profit that does not exist, and the effect compounds with trade frequency.
Commission and swap are not tester inputs. They come from the symbol specification on your broker's server, so a test on a raw spread symbol that charges commission only includes it if that symbol's spec carries it. Otherwise build a custom symbol with your real costs, or subtract the cost per trade by hand before reading the result. A strategy with a thin edge and many trades lives or dies here.
Period. Long enough to include more than one market condition, and specifically to include the conditions that hurt. A test covering only a trending stretch tells you about trending stretches.
If you trade gold, run the test at the spread gold actually carries, which is wider than most pairs and widens further around news. Why that matters more on XAUUSD is in trading gold on a prop firm challenge.
- Modelling: real tick data on anything that trades intraday.
- Spread: what your broker charges, not the tester default.
- Commission: included if your account type has one.
- Period: long enough to include a condition that hurts.
Optimisation, and the trap inside it
The tester can try thousands of settings combinations and report the best. This is seductive and it is where most backtests become fiction.
The best performing combination over a historical period is, by definition, the one that fit that period most closely. Some of that fit is the strategy working and some is coincidence, and the tester cannot tell you which. Run enough combinations and you will always find one that looks exceptional, including for a strategy that has no edge at all.
The defence is simple and almost nobody applies it. Optimise on one period, then test the chosen settings on a different period the optimiser never saw. If the result collapses, the settings were fitted to noise. If it degrades but survives, you have something.
Be suspicious of any result that depends on a setting being exactly right. A strategy that only works at a stop of 37 points and fails at 35 and 40 has found a coincidence rather than a behaviour.
How to read the report
Three numbers before profit, in this order.
Maximum drawdown. Read the Equity Drawdown lines rather than the balance ones, because an open loser counts against a firm's limit while it is still open. And convert before comparing: the tester's relative drawdown is a percentage of its own peak, while your firm measures against the initial balance or a trailing high water mark, so the two are not the same measurement.
Trade count. Under roughly a hundred trades the result is noise regardless of how good it looks. Twenty profitable trades is a sample that a strategy with no edge produces regularly.
Then expected payoff, which is what the report calls expectancy and is already in account currency. Read it next to Total Trades and Profit Factor, and treat a profit factor much above two over a few hundred trades as a reason to re-check the modelling and the costs rather than as a result.
Only after those three does total profit mean anything. What each metric actually measures, and why win rate is near the bottom of the list, is in an eighty percent win rate can still lose the account.
What comes after the backtest
A backtest cannot model three things that decide live results, so the sequence after it is not optional.
It cannot model slippage and real fills, which is why a demo account on the same broker comes next. It cannot model the terminal being closed or the server dropping, which is why the next step after that is running it somewhere that stays on, covered in do you need a VPS. And it cannot model you, which is why the smallest live account available comes before any funded one.
If the destination is a prop firm account, there is a fourth step the tester knows nothing about: whether the settings respect that firm's limits and whether the firm permits automation at all. The checklist is in the rulebook checklist and prop firms that allow EAs.
Trading carries risk. A backtest that survives all of this is evidence the logic is coherent, not a projection of what any account will do.
Frequently asked questions
How do you backtest an EA properly?
Use real tick data on anything that trades intraday, set spread and commission to what your broker actually charges, and run a period long enough to include a market condition that hurts the strategy rather than only one that suits it.
Why do backtests look so much better than live results?
Usually a combination of unrealistic spread, no commission, modelling quality too low to represent intraday price, a period that excluded the hard conditions, and settings that were optimised to fit that exact history.
What is wrong with optimising an EA?
The best performing combination over a historical period is the one that fit that period most closely, and the tester cannot separate genuine behaviour from coincidence. The defence is to optimise on one period and then test those settings on a period the optimiser never saw.
What should I look at first in a backtest report?
Maximum drawdown, then trade count, then expectancy per trade in currency. Profit is the last number that matters, because a large profit over thirty trades with a forty percent drawdown is not a usable result.
How many trades does a backtest need to mean something?
Roughly a hundred as a floor for most approaches, and even then a single favourable market regime can carry the result. Twenty profitable trades is a sample that a strategy with no edge produces regularly.
Want the bot that runs this discipline for you?