How to Backtest an EA in MT5 with the Strategy Tester
EABuild Team · · 10 min read

If you want to backtest an EA in MT5, the Strategy Tester built into MetaTrader 5 is the tool to use. A backtest (a replay of an expert advisor over stored price history) shows how the EA's rules would have behaved in the past, which helps you spot setup mistakes and understand how the strategy works. This guide covers what to prepare, the numbered steps in the tester, how to read the report, and why the result is never a forecast.
What you need before you start
A backtest only works when three things are in place: the EA file, the price history and a clear question. Spend a few minutes on each, because most poor backtests come from a rushed start.
The EA file and its settings
The EA must be a compiled file (an .ex5) in the Experts folder of your MetaTrader 5 data folder. If you have not copied it there yet, follow the guide on how to install an EA in MT5, then restart the terminal or refresh the Navigator so the EA appears in the list.
Most EAs also come with set files (saved lists of input settings you load in MetaTrader). Decide which set file you are testing before you press start, and write its name down. A result is only meaningful when you know exactly which inputs produced it.
The symbol and timeframe from the listing
Test the symbol and timeframe the EA is listed for. An EA designed for XAUUSD on M15 tells you little when you run it on another symbol or timeframe, because its logic was not built for that market. Check that your broker uses the same symbol name, since some brokers add a suffix.
A question the test should answer
Decide what you want to learn. Good questions are practical: Does the EA open and close trades the way its description says? How deep does the drawdown (the drop from the account's peak) get during a rough period? Does it behave sensibly when spreads widen? A vague wish to see whether it makes money invites you to tune settings until the chart looks good, which is a trap covered later.
Step by step: running a backtest in the MT5 Strategy Tester
The order below follows the tester's Settings tab from top to bottom. The wording of some options differs slightly between builds, so treat it as a map rather than a script.
- Open the tester. In MetaTrader 5 choose View, then Strategy Tester, or press Ctrl+R. The panel opens at the bottom of the terminal.
- Open the Settings tab. Set the first dropdown to the tester mode for a single test, which the tester lists as Expert Advisor. Pick your EA in the Expert field.
- Set the symbol and timeframe. Enter the symbol the EA is listed for and select its timeframe, for example XAUUSD and M15.
- Choose the date range. Use a custom range, not just the shortest default. A period that includes both calm and volatile weeks tells you more than one quiet month. The tester can also hold back a forward period, which you can leave off for a first test.
- Choose the modelling mode. This is the most important setting. The next section explains each option.
- Set the deposit and leverage. Use the deposit, currency and leverage of the account you would actually use. If the EA lists a recommended minimum deposit, start there, not with an unrealistically large balance that hides drawdown.
- Leave optimisation off. For a first run, keep the optimisation dropdown on Disabled. You want one clean test of one set of inputs.
- Load the inputs. Open the Inputs tab, right-click, and choose Load to pick the set file you noted earlier. Check a few key values on screen.
- Start the test. Press Start. Turn on Visual mode if you want to watch trades appear on a chart; it runs slower, but it is the quickest way to confirm that the EA does what you expect.
- Read the results tabs. When the run finishes, open Backtest, Graph and Overview (the names can vary by build) and the Journal. The sections below explain what to look at.
Choosing a modelling mode
The modelling mode decides how closely the tester imitates real price movement inside each bar. A slower mode is closer to real trading; a faster one is quicker but rougher. MT5 offers these choices.
- Every tick based on real ticks. The tester replays the tick history your broker supplied. It is the slowest mode and the closest to live conditions, and it needs the broker's tick history to be available and complete.
- Every tick. The tester generates ticks from the minute bars. It is faster than real ticks, but the ticks are simulated, so intrabar movement is an estimate.
- 1 minute OHLC. The tester uses the open, high, low and close of each minute bar. It is quick, but fast scalping logic can be misjudged because it never sees the order of price moves inside the minute.
- Open prices only. The tester acts only at the open of each bar. It is suitable only for EAs that explicitly work on bar opens; it is a poor fit for anything that reacts to price during a bar.
As a rule, an EA that trades inside a bar, such as a scalper, a grid or a news strategy, needs one of the two tick modes to give a believable picture. Run the quick mode to check your settings, then repeat the final test in real ticks.
Spread, slippage and delays
Your result depends heavily on trading costs. MT5 uses the spread (the gap between the buy and sell price) recorded in the history, so a broker's history with unusually tight spreads makes an EA look cheaper to run than it will be live. The tester also lets you add an execution delay, which approximates the lag between your order and the fill. Use a delay when you test a fast strategy, because instant fills are rare in real trading.
Commission and swap (the overnight financing charge) also matter. Check the contract details of the symbol with your broker, and remember that the tester follows the symbol specification it has stored.
Reading the report
After the run, the Backtest tab lists the numbers and the Graph tab shows the balance and equity curves. The balance line moves when trades close, and the equity line includes open trades, so equity is the more honest picture of risk.
The figures worth checking first
- Maximal drawdown. Look at the equity drawdown, not only the balance drawdown. Ask yourself whether you could sit through that drop with your own account.
- Total trades. A handful of trades says very little. A longer run gives you more to judge.
- Profit factor and expected payoff. These summarise gross profit against gross loss, and the average result per trade. Treat them as descriptions of one historical run, not as a promise.
- Largest losing trade and consecutive losses. These show how bad a bad streak became. For grid and martingale EAs they are especially revealing.
- History quality. The tester reports how much of the period was covered by real data. A low figure means the result rests on gaps and estimates.
The Journal and the trade list
Do not stop at the summary. Open the Journal to read errors such as missing history, rejected orders or invalid lot sizes. Then scan the list of deals. If trades cluster in odd places, or the EA stops trading for weeks, the cause is usually a setting, a symbol mismatch or a data gap, and the journal often says which.
Backtesting grid, martingale and hedging EAs
Some EAs deserve extra care when you test them. A grid strategy opens extra orders at set price steps, and martingale means increasing the lot size after a losing trade. Both can show a smooth equity line for a long stretch and then a sharp drawdown when price keeps moving one way. Hedging means holding buy and sell positions on the same symbol at once, and it requires an account type that allows it.
The shop lists several MT5 EAs of this kind, all of them listed for XAUUSD (gold). Mad Turtle EA for MT5 is listed for XAUUSD on H1 and M15, uses scalping, grid and martingale logic, and comes with an EA file and 7 set files. When you test it, run each set file separately so you can compare them on the same dates and settings.
Goldex AI EA for MT5 is listed for XAUUSD on the M5 timeframe, with hedging, martingale and news trading, and comes with 3 set files and a PDF guide. A news trading strategy acts around economic releases, when spreads can widen and slippage is common, so the spread and delay settings above matter even more. Read the PDF guide before you decide which inputs to test.
Forex GOLD EA for MT5 is listed for XAUUSD and EURUSD on M15, with grid, martingale and hedging logic, and a package of two compiled files and 11 set files. With that many set files, keep a simple table of which file you ran, the date range and the drawdown you saw.
For each of these, watch the equity curve and the largest drawdown rather than the final balance. If you want background on how gold EAs make decisions, the gold EA guide explains the common strategy types.
Why a backtest is not a forecast
A backtest answers a narrow question: how would these rules have behaved on this data, under these assumptions? It cannot tell you what the market will do next. Several limits apply to every test.
- The past does not repeat on schedule. A market regime that suited the EA last year may not return.
- Over-fitting. If you change inputs again and again until the curve looks good, you have fitted the EA to old data. The result then says more about your tuning than about the strategy.
- Data differences. Your broker's history, spreads and execution differ from another broker's and from live conditions.
- Costs and fills. The tester fills orders in a clean way. Real accounts see slippage, requotes and occasional rejections.
To reduce these problems, test more than one period, including an awkward one. Keep a section of history you never tuned on and test it once at the end. Then run the EA on a demo account for a while and compare what happens there with the tester, since a demo uses live prices and execution.
Common problems and quick checks
- No trades at all. Check the symbol name, the timeframe, the lot size against the symbol's minimum, and whether the EA needs a particular input switched on. Read the Journal.
- The EA is missing from the list. It is probably not in the Experts folder, or it has not been compiled. Refresh the Navigator or restart the terminal.
- The test is very slow. Real ticks over a long period take time. Shorten the range for trial runs, or use a faster mode only to check the setup.
- Results change between runs. Confirm the date range, modelling mode, deposit and inputs are identical. Real tick history can also be downloaded in between, which changes the data.
- Low history quality. Let MetaTrader download more history for the symbol, then run again.
Next steps
Once you have a clean test, move to a demo account and watch the EA there before you consider live trading. Every product in the shop is a digital download, and all of them are included in the membership, so you can test several EAs side by side on the same dates and settings.
Trading foreign exchange and CFDs carries a high level of risk and may not be suitable for all investors. Past performance does not guarantee future results; only trade with money you can afford to lose.
Tags: Strategy Testing, Expert Advisors, Gold EAs


