MT5 Lab

How to Backtest an EA in MT5: A Reproducible Workflow

Run a reproducible MT5 Strategy Tester backtest, choose a modelling mode, inspect the Journal, and separate development data from validation data.

한국어 원문 읽기

Key takeaways

A useful backtest is a recorded experiment: save the EA version, exact symbol, timeframe, dates, modelling mode, account settings, and inputs.

In current MT5 builds, Overview is primarily a task launcher and previous-results screen; test statistics appear under Backtest or Results, depending on the build.

Use the Journal and a visual run to validate execution before comparing performance across development, out-of-sample, and stress periods.

How to backtest an Expert Advisor in MT5

Key takeaways

  • Treat every backtest as a reproducible experiment, not as proof that an EA will make money.
  • Validate the test itself first: confirm the correct EA and inputs loaded, inspect the Journal, and watch at least one short visual run.
  • Compare unchanged rules across separate time windows. A polished result from one selected period is not evidence of robustness.

MetaTrader 5 Strategy Tester can replay an Expert Advisor against historical market data. It is useful for checking execution logic, studying risk, and finding failure modes before a demo or live deployment. It cannot reproduce every future spread, fill, outage, liquidity event, or change in market behaviour.

The practical goal is therefore not to produce the most attractive equity curve. It is to create a test that another person—or you, several months later—can rerun from the same code, inputs, market symbol, and data assumptions.

MetaQuotes documents the tester's controls and modelling modes in its official Strategy Testing guide opens in a new tab. Keep that reference open because labels can move between MT5 builds and broker-distributed terminals.

Before opening Strategy Tester

Prepare these items first:

ItemWhat to record
EA source and binaryFile name, version or commit, and compile date
Compile result0 errors; investigate warnings that affect logic or types
TerminalMT5 build number from Help → About
Account environmentServer name, account currency, account type, and leverage
InstrumentThe exact server-side symbol, such as EURUSD, EURUSD.a, or another suffix
Contract specificationDigits, tick size, tick value, volume step, stops level, trading sessions, commission, and swap
Historical windowEarliest and latest dates that are actually available for the symbol

An exact symbol matters. Two brokers can expose instruments with similar display names but different contract sizes, price precision, sessions, costs, and minimum stop distances. Results are not portable simply because the chart label looks familiar.

If you do not yet have a compiled EA, start with Build and Run Your First MQL5 EA.

MetaEditor showing a successful compile with zero errors and zero warnings
Compile the exact EA version you intend to test before opening Strategy Tester

Open Strategy Tester and find the right screen

Press Ctrl+R, or choose View → Strategy Tester. Depending on the terminal build, the panel may show tabs such as Overview, Settings, Inputs, Backtest, Graph, Agents, and Journal.

Overview is not normally the performance report. In current builds it acts mainly as a task launcher—with cards such as Single, Visualize, or Optimization—and as a list of previous runs. Configure a single test in Settings. After the run, look for statistics in Backtest; some builds or older documentation call the corresponding area Results.

MT5 Strategy Tester Settings with the Expert, symbol, timeframe, dates, deposit, and leverage selected
Record every setting that can change the test before pressing Start
The screenshot illustrates where the controls are. Its 2026.12.31 end date is a future placeholder, not a completed historical test. For a reproducible run, choose a completed past end date within the history actually available from the selected server.

Configure one controlled baseline

Do not change several things at once. Establish one baseline run and write down the settings below.

SettingHow to choose itWhy it changes the result
ExpertSelect the compiled EA version under testA similarly named binary may contain different logic
SymbolUse the exact symbol from the intended account environmentContract rules and historical data are symbol-specific
TimeframeMatch the timeframe the strategy was designed to readBar-dependent signals change when the period changes
DateEnter explicit start and end datesRelative presets move over time and are hard to reproduce
ForwardLeave off for the first diagnostic run; plan a separate holdout laterForward selection changes which data is used for development and validation
DepositMatch the comparison scenario and keep it unchangedMargin, position sizing, and percentage drawdown depend on it
LeverageMatch the target account specificationIt affects margin availability, not the quality of the trading rule
Execution delayRecord the selected delay model, if availableA zero-delay run can hide timing sensitivity
OptimizationDisable it for the baselineA single run is easier to diagnose before parameter search

There is no universally correct deposit, leverage, symbol, or timeframe. The defensible choice is the one that matches the environment you are studying and is recorded precisely enough to repeat.

Choose a modelling mode that matches the EA

MT5 may offer several tick-generation modes. Faster is not automatically better, and slower is not automatically more realistic.

ModeAppropriate useImportant limitation
Every tick based on real ticksFinal verification when broker-provided real-tick history is availableAvailability and history coverage vary; it still does not reproduce future execution
Every tickLogic that depends on intrabar prices when real ticks are unavailableTicks are generated from lower-timeframe data rather than observed tick-for-tick
1 minute OHLCFaster diagnostic runs for logic that does not require the path within each minuteStops and intraminute sequencing can differ from tick-based results
Open prices onlyEAs deliberately designed to act once at a new barUnsuitable when entries, exits, trailing stops, or indicators depend on intrabar movement

Use a faster mode to find obvious code defects, then rerun important candidates with the most appropriate higher-detail mode. If a strategy changes character when you switch modes, investigate why instead of choosing the prettier result.

Also check the date range reported by the tester. A requested three-year run is not truly a three-year experiment if the symbol history begins halfway through it.

Save and verify Inputs

Open Inputs and record every non-default value. When the terminal offers Save/Load, export a .set file alongside the test notes. Give it a name that identifies the EA, symbol, timeframe, and date, for example:

first-candle-ea_v1.1_EURUSD_H1_2023-01-01_2025-12-31.set

For a simple EA, the list may include:

InputVerification question
Volume or risk inputIs sizing fixed, balance-based, or stop-distance-based?
Stop-loss distanceIs the unit points, price, pips, ticks, or volatility?
Take-profit distanceIs it valid for this symbol's tick size and stops level?
Session filterWhich server timezone does it use?
Signal timeframeDoes it use the chart/test timeframe or an internal period?
Magic numberCan its orders be separated from other EAs?

Never assume a label ending in Points means pips. In MQL5, _Point is the symbol's point value; the valid tradable increment can also be constrained by tick size.

Run a short visual test before a long batch

Turn on visual mode for a short, representative interval. The purpose is debugging, not admiring the simulated profit.

Watch for these behaviours:

  1. The EA waits for the intended signal rather than trading immediately by accident.
  2. Entry direction and timing match the written strategy rule.
  3. It does not submit duplicate orders on every tick.
  4. Stop loss and take profit appear on the correct side of the market.
  5. Opposite-signal exits occur only for the selected matching-magic position; a hedging account still requires ticket-level enumeration.
  6. Positions do not remain open outside the intended session or at the end of the test unexpectedly.

Then inspect Journal. Repeated errors such as invalid stops, insufficient funds, a disabled market, or failed price access invalidate the interpretation of the performance statistics until the execution problem is understood.

Strategy Tester visual mode showing an invalid-stops message in the Journal
A completed test can still be unusable when the Journal shows repeated order rejection

If you see invalid-stops errors, use How to Fix “Invalid Stops” in MT5 before comparing returns.

Separate development from validation

Running the same period repeatedly while changing parameters turns that period into development data, even if you never call it optimization. Reserve data that you do not inspect while designing the rules.

One practical structure is:

WindowPurposeRule
DevelopmentFind defects and make deliberate rule changesChanges are allowed, but document each one
Out-of-sampleCheck the frozen EA and inputs on unseen datesDo not retune after seeing the result without declaring a new research cycle
Stress periodsStudy gaps, spread expansion, trends, ranges, or high volatilityUse named dates and explain why they were selected
Forward demoObserve current quotes, sessions, and execution behaviourDo not treat demo fills as identical to live fills

Use multiple contiguous windows rather than searching for a favourable start date. Keep the EA, inputs, symbol, timeframe, and sizing unchanged when the question is “does the same configuration behave differently over time?”

A reproducible test record

Copy this template into a plain-text note, spreadsheet, or repository issue for every run you plan to compare:

Test ID:
Run timestamp and timezone:
MT5 build / server:
EA file / version / commit:
Symbol / contract notes:
Timeframe:
Start date / end date:
Modelling mode:
History coverage / quality shown:
Execution delay setting:
Deposit / currency / leverage:
Inputs file:
Commission / swap / spread assumptions:
Journal warnings or errors:
Report export path:
Reason for this run:
Decision and next test:

Screenshots are useful evidence, but they are not a complete experiment record. They often omit the build, exact dates, hidden inputs, data coverage, and the EA version.

What to inspect after the run

Use this order:

  1. Journal: Were data and trade operations valid?
  2. Settings and Inputs: Can the run be reproduced?
  3. Backtest or Results: How many trades occurred, and what were the net result and drawdowns?
  4. Deal/order history: Did entries and exits follow the rule?
  5. Graph: Did open-equity risk diverge from the closed-balance curve?

Do not begin with Total Net Profit. A positive result may be dominated by one outlier, based on very few observations, or produced while intended orders were repeatedly rejected.

The companion guide, How to Read an MT5 Strategy Tester Report, explains this sequence and the main statistics in detail.

Pre-demo checklist

  • The exact EA version compiles and is archived with its inputs.
  • The symbol specification and available history have been recorded.
  • A visual run confirms entries, exits, and position limits.
  • The Journal has no unexplained recurring errors.
  • The detailed modelling run does not reveal behaviour hidden by the faster run.
  • Development and out-of-sample dates are clearly separated.
  • Results have been compared across unchanged, contiguous windows.
  • Costs, spread behaviour, delay, and data limitations are stated.
  • The conclusion describes uncertainty and failure modes, not a profit promise.

Passing this checklist does not make an EA safe or profitable. It means the backtest is documented well enough to justify the next research step.

Frequently asked questions

Why does my Backtest tab not appear?

Tab names vary by MT5 build and terminal distribution. Finish a single test, then look for Backtest or Results. Overview is generally the task/start screen, not the statistics report.

Should I enable optimization immediately?

No. First prove that one configuration executes as designed and produces a reproducible report. Optimization multiplies both useful experiments and hidden mistakes.

Is “Every tick based on real ticks” the same as live trading?

No. It can provide more detailed historical price paths when real-tick data is available, but it cannot know future liquidity, delays, rejected orders, disconnections, or your live account's fills.

Can I compare results from two brokers?

Only with explicit caveats. Compare symbol specifications, sessions, historical coverage, spreads, commissions, swaps, and execution assumptions first. A matching instrument name is not enough.

Risk note

Backtests are simulations based on historical data and selected assumptions. They do not guarantee future performance. Leveraged products can produce losses larger and faster than an unleveraged cash position, and an automated system can repeat a faulty rule without human intervention.

This guide is educational and does not recommend a broker, instrument, EA, or trade. Verify current tester behaviour in the official Strategy Testing documentation opens in a new tab and the MQL5 program-testing reference opens in a new tab.

Up next

Next, read How to Read an MT5 Strategy Tester Report. It shows how to audit the Journal first, locate statistics under Backtest or Results, distinguish balance from equity drawdown, and detect a result dominated by a few trades.