How to Backtest an EA in the MT4 Strategy Tester
Learning how to backtest an EA in the MT4 Strategy Tester is the single best way to find out whether an expert advisor stands a chance before you risk real money on it. Done properly, it also exposes how much your broker's spreads, commissions and slippage eat into the strategy's edge — which is where most backtests quietly fall apart.
What the MT4 Strategy Tester Actually Does
The Strategy Tester is a built-in MT4 module that replays historical price data through your EA's code, simulating trades bar-by-bar (or tick-by-tick, depending on mode) and logging every entry, exit, and account change. It's free, it's fast, and it's the first filter every EA should pass through before demo or live testing.
What it's good at:
- Rapid iteration — test hundreds of parameter combinations in minutes via Optimization mode
- Logic verification — confirming the EA enters/exits when it's supposed to
- Rough equity curve shape — spotting obvious drawdown spirals or flat periods
What it's genuinely poor at, unless you configure it carefully:
- Realistic cost modelling — default settings often ignore variable spread and commission
- Slippage and requotes — these don't exist in a basic backtest at all
- Broker-specific execution quirks — MT4 testing assumes a generic fill, not your actual server's behaviour
That second list is why a backtest showing a glowing equity curve can still lose money live. The gap is almost always cost-related, not logic-related.
Setting Up Your First Backtest
Open the Strategy Tester (View → Strategy Tester, or Ctrl+R) and work through these steps in order:
1. Choose the Expert Advisor from the dropdown — it must already be compiled with no errors 2. Select the symbol and timeframe the EA was designed for (don't test an H1 scalper on D1 data) 3. Set the model: "Every tick" is slowest but most accurate; "Control points" and "Open prices only" are faster but can hide real behaviour, especially on EAs that manage trades intrabar 4. Set spread: switch from "Current" to a fixed custom value that reflects what you'd actually pay — pull this from your broker's live spread page or PipTax's own cost tool rather than guessing 5. Set initial deposit and leverage to match the account type you'd actually trade 6. Pick a date range long enough to cover multiple market regimes — a few months of trending data will flatter almost any trend-following EA
Click Start. The report tab at the end gives you net profit, drawdown, profit factor, and a full trade log — treat all of it as provisional until you've stress-tested the assumptions below.
Why Spread and Commission Settings Make or Break Your Results
This is the part most retail traders skip, and it's the part that matters most. MT4's default tester spread is often a single fixed number pulled from whatever your demo server happens to be quoting — not the variable, volatility-sensitive spread you'd face on a live ECN or raw account.
Before you trust any backtest number:
- Check whether your broker uses fixed or variable spreads, and test both the typical and the stressed (news-time) spread
- Add commission per lot manually if your account type charges one — MT4's backtester doesn't always apply this automatically depending on build and broker config
- Run the same EA and date range with two or three different spread assumptions and compare the profit factor — if the strategy only works at the tightest spread, it's fragile
- Remember that swap/rollover costs compound differently EA to EA; a high-frequency scalper barely notices them, a multi-day swing EA can be wiped out by them
Two brokers with identical "looks fine on paper" spreads can produce very different backtest outcomes once commission structure is added. Rather than estimate this by hand, run your EA's typical trade size and holding period through PipTax's cost tool at /audit.html — it shows the real cost-per-trade impact so your tester spread setting matches reality rather than guesswork.
Reading the Strategy Tester Report Properly
The summary numbers at the top are a starting point, not a verdict. Work through the report in this order:
| Metric | What to check | |---|---| | Total trades | Enough trades (100+) to be statistically meaningful? | | Profit factor | Above 1.0 is not enough — look for consistency, not just the headline number | | Max drawdown | Could you psychologically and financially survive this, doubled? | | Consecutive losses | How many losing trades in a row did the EA produce? | | Average trade duration vs spread cost | Short holding periods are most vulnerable to spread/commission drag |
Also open the full trade log, not just the summary. Look for:
- Trades that only work because of unrealistic fills at gaps or weekends
- Clusters of wins concentrated in one short period (curve-fitting red flag)
- Whether the equity curve relies on a handful of outsized winners
Common Mistakes That Invalidate a Backtest
- Over-optimising on one data set until it fits perfectly, then being shocked when it fails on new data (classic curve-fitting)
- Ignoring broker-specific execution — an EA tested with zero slippage will behave differently on a live account during news
- Testing too short a period — three months of calm trending conditions tells you nothing about how the EA handles a ranging or volatile regime
- Using "Open prices only" mode for EAs that manage stop losses or trailing stops intrabar — this mode can't see what happens between bars
- Never testing out-of-sample — always hold back a chunk of history the EA wasn't optimised on, and check performance there too
From Strategy Tester to Demo to Live
A clean Strategy Tester result earns the EA a demo run — nothing more. Suggested sequence:
1. Backtest across multiple spread/commission assumptions and multiple market regimes 2. Forward test on demo for several weeks, ideally on the same broker and account type you intend to trade live, so execution and spreads match what you modelled 3. Compare demo trade logs against the backtest — if live spread or slippage is consistently worse than assumed, revisit your MT4 Strategy Tester settings and re-test 4. Go live small, and keep comparing actual cost-per-trade against your original assumptions
Throughout this process, keep your cost assumptions anchored to something real. Compare account types and typical spread/commission structures on PipTax's broker pages at /brokers/index.html, and if you're deciding between an ECN-style raw spread account versus a standard commission-free account for your EA, the /cost-impact.html page walks through how that choice changes total trading cost over a year of typical activity.
Conclusion
Knowing how to backtest an EA in the MT4 Strategy Tester properly — meaning with realistic spread, commission and slippage assumptions, tested across several market regimes and validated out-of-sample — is what separates a robust strategy from a curve-fitted one that only ever worked on a chart. Treat the Strategy Tester as the first checkpoint, not the final word, and always confirm your cost assumptions against live broker data before risking real capital.
Key takeaways
- The MT4 Strategy Tester is free and fast but defaults to unrealistic spread/commission assumptions — always set these manually before trusting a result
- Use 'Every tick' mode for EAs that manage trades intrabar; 'Open prices only' can hide real behaviour
- Test across multiple market regimes and hold back out-of-sample data to avoid curve-fitting
- A backtest's profit factor and drawdown numbers are a starting point, not a verdict — read the full trade log too
- Match your tester's spread/commission settings to real broker data via PipTax's cost tool before moving to demo or live
- A clean backtest only earns an EA a demo run, not a live account
Frequently asked questions
- Does the MT4 Strategy Tester account for spread and commission automatically?
- Not reliably. The default tester often uses a single fixed spread value and may not apply commission at all depending on your broker's configuration and MT4 build. You usually need to set a custom fixed spread manually and add commission per lot yourself to get a realistic result.
- What's the difference between "Every tick" and "Open prices only" testing modes?
- "Every tick" simulates price movement within each bar for the most accurate (but slowest) results. "Open prices only" only checks the bar's opening price, which is fast but can miss how an EA behaves intrabar — risky for EAs that manage stop losses or trailing stops.
- How much historical data should I use to backtest an EA?
- Enough to cover multiple market regimes — trending, ranging, and at least one high-volatility period. A few months of calm trending data will make almost any trend-following EA look better than it is.
- Why did my EA perform well in backtesting but lose money live?
- The most common cause is unrealistic cost assumptions in the tester — spread, commission and slippage are usually understated versus live conditions. Curve-fitting to historical data and skipping out-of-sample testing are the next most common causes.
- Should I test the same EA on different brokers?
- Yes, if you're deciding where to trade it live. Spread and commission structures vary between brokers and account types, so the same EA can show meaningfully different net results. Use PipTax's cost tool to compare realistic cost assumptions before committing.