How to Backtest a Forex Strategy: A Practical Guide for MT4 Users
Platform scope: MetaTrader 4 desktop. The rule sheet and price paths below are hypothetical teaching examples, not results from a trading test.
To backtest a forex strategy, define exactly what would trigger a trade, apply those rules to historical information without seeing the future, and calculate the result under recorded data and cost assumptions. In MT4, you can automate that process with an Expert Advisor or work through it manually when the decisions require judgement. Either way, a useful test should let you explain why each trade happened and reproduce the calculation later.
The difficult part is making the historical exercise resemble the decision you could actually have made. A profitable report means little if an indicator used information that was unavailable at entry, the stop was tested against an invented price sequence, or transaction costs were left unexplained. The workflow below makes those assumptions visible before you judge the strategy.

Choose an EA backtest or a manual backtest
MT4's Strategy Tester runs an Expert Advisor, or EA, on historical data. An indicator can help an EA calculate a signal, but placing an indicator on a chart does not supply the missing entry, exit and position-sizing rules. The EA must implement the strategy you intend to evaluate. MetaQuotes describes the tester's purpose and its execution limits in the MQL4 testing documentation.
Manual backtesting suits an idea that still contains discretionary decisions, such as which price swing defines a trading range. You reveal historical information in sequence, record the decision before advancing, and maintain your own trade ledger. A hand-marked chart is not an automated MT4 performance report. If another reviewer cannot understand your entries from the written rules, refine those rules before increasing the sample.
Write one testable version of the strategy
Replace descriptions such as “buy when the trend looks strong” with decisions that have an observable answer. Include the price used for an entry, how an existing trade affects the next signal, and what happens when an order cannot be placed. Otherwise, two people can apparently test the same strategy and produce different trades.
| Decision | Example specification |
|---|---|
| Market and direction | EUR/USD, H1, long positions only, with at most one position open. |
| Signal | On completed candles, the 20-period simple moving average of closes moves above the 50-period average after being at or below it on the preceding candle. |
| Entry | Use the first available Ask of the next H1 candle. Ignore another signal while a position is open. |
| Size | Use a fixed 0.01 lot only if permitted by the selected symbol's contract and volume limits. |
| Exit | Set a stop 20 conventional EUR/USD pips below the actual entry and a target 30 pips above it. Close any remaining position at the test boundary and identify that exit separately. |
| Exceptions | Log missing prices, rejected orders and invalid stop or volume settings. Do not silently turn an unsuccessful order attempt into a filled trade. |
These values illustrate specification writing; they are not recommended parameters or a supplied EA. An automated test requires code that implements and verifies them. If you change the rule after examining results, give the revised version a new identifier. Preserve the original ledger so that a later comparison includes the unsuccessful ideas as well as the attractive ones.
Position sizing deserves its own rule. A fixed lot size and a fixed percentage of equity produce different account paths even with identical signals. Define the stop and the permitted account exposure together; our guide to position sizing and stop-loss orders explains that relationship.
Prepare the history and record where it came from
Choose the development period before inspecting its best-looking trades. Record the broker or data provider, exact symbol name, server time zone, date range and available lower-timeframe coverage. Leave enough earlier history for the indicators to initialize. A test that begins with an incomplete moving average is not evaluating the same rule as one using the full lookback.
Open Tools → History Center, or press F2, to inspect a symbol's historical bars. Preserve an export or backup before importing or replacing data. MetaQuotes cautions that History Center downloads can differ from a broker's own history; the download also recalculates higher timeframes from M1 data and adjusts time to the active account. A longer dataset therefore needs a provenance note, not just a larger bar count.
For a session-based strategy, specify how you translate chart time into the intended market session on each date. Keep that decision consistent through daylight-saving changes. Document any gap or questionable candle you exclude and the reason for doing so. Removing a period because it lost money changes the question your test answers.
Set up one reproducible MT4 tester run
Open Strategy Tester with Ctrl+R; the MT4 shortcut guide covers the related desktop controls. Start with one specified run before exploring parameter combinations.
- Select the compiled EA, symbol and timeframe. Check that the EA version matches your rule sheet.
- Enable Use date and enter the intended period. In Expert properties, set the deposit, account currency, permitted direction and input values.
- Choose the modelling method and record the spread assumption. Leave Optimization off for this single run.
- Use Visual mode on a short interval to inspect entries and exits, then run the full period with the same verified configuration.
MetaQuotes documents these controls in Tester Setup. Save the input set and a configuration record alongside the result. Include the terminal build, initial capital, sizing rule and symbol contract details; a screenshot of the final profit figure cannot capture those assumptions.
During the visual check, investigate discrepancies instead of judging profitability. Did the EA act on a completed candle? Did it open one position or several? Was a stop modification accepted? An EA that fetches an external service also needs special attention: WebRequest is not executed in MT4's tester, so a live data dependency cannot be assumed to work unchanged.
Understand what MT4's modelling modes can tell you
| Mode | Appropriate interpretation | Question to resolve |
|---|---|---|
| Open prices only | A fast approach intended for completed-bar logic. | Can any entry, stop, target or adjustment depend on movement inside the candle? |
| Control points | A rough estimate using lower-timeframe information and interpolation. | Would a more detailed price path change the apparent outcome? |
| Every tick | Generated ticks based on available lower-timeframe OHLC data, with interpolation between control points. | Is lower-timeframe coverage sufficient, and is the strategy sensitive to the unknown sequence between recorded prices? |
The official MT4 modelling explanation makes that interpolation explicit. MT4 Every tick does not mean a replay of recorded historical ticks. MT5 has a separately documented real-tick testing mode; the platforms' terminology should not be treated as interchangeable. See our MT4 and MT5 comparison for broader platform differences.
Consider a hypothetical candle with an open of 1.1000, high of 1.1020, low of 1.0980 and close of 1.1010. For a buy at 1.1000, a target at 1.1015 and a stop at 1.0990, a path visiting the high first can reach the target first. A path visiting the low first can hit the stop first. Both have identical OHLC values. This illustration ignores spread and execution costs to isolate the sequencing problem.
A strategy can enter only at candle opens and still depend on intrabar prices through its protective orders. Choosing Open prices only because the entry signal uses closed candles does not settle that issue. Inspect the execution rules and use the most suitable available data, while keeping the remaining uncertainty visible.
Make spread and other costs explicit
In the standard MT4 setup, Current spread means the spread captured at the start of the test; it does not recreate historical spread changes. The Spread setting also accepts a custom value. For a repeatable comparison, record an explicit fixed-spread scenario and rerun with other justified assumptions. A value observed during a quiet session may be unsuitable for a strategy trading a busy announcement.
Check units before entering a number. MQL4's symbol properties express spread in points. On a five-decimal EUR/USD quote, a point of 0.00001 makes 20 points equal to 0.00020, or two conventional pips. That conversion should not be copied blindly to every instrument.
Record what the test actually charges for commission and overnight financing. A zero entry can mean a zero assumption, so compare it with the account terms you intend to model. Do not deduct spread again if the simulated entry and exit prices already include it. The spread and transaction-cost guide explains how the components differ.
For a separate estimate, the ForexSignal24 spread and commission calculator uses manual inputs; it does not provide a historical cost feed and excludes swap and slippage. Treat it as a way to check a stated scenario. Every tick modelling alone does not establish that live latency, spread widening or adverse fills have been reproduced.
Run a manual backtest without seeing the next decision
If the rules are discretionary, turn off chart Auto Scroll, move to your chosen historical starting point and keep subsequent bars outside the visible area. Reveal information in sequence, using only candles that would have been complete at the decision time. Keep every chart in a multi-timeframe review at the same historical cutoff. Inspecting a fully formed higher-timeframe candle too early can reveal the future.
Before advancing, record the timestamp, whether the setup qualifies, the intended entry, stop, target, size and reason for skipping or taking it. After the outcome becomes visible, add exit details, costs and the resulting gain or loss. Retain ambiguous setups and rule violations as labelled records. Screenshots taken at the decision point are useful evidence when the strategy relies on drawn levels.
If both a stop and target lie inside one bar, consult suitable lower-timeframe information. If the order remains unknown, label the trade unresolved or apply an uncertainty rule chosen before the test. Do not award the favourable exit after seeing the result. Likewise, an indicator that redraws historical signals needs a record of what was visible at decision time; its final chart is insufficient evidence.
Evaluate an untouched period and preserve the evidence
Use a chronological development period to define the rules, then reserve a later period for evaluation. Freeze the rules before opening that later sample. If its results persuade you to change a parameter, that sample has become part of development; the revised idea needs fresh evaluation. Repeatedly trying alternatives on the same “holdout” removes the separation you intended to create.
Compare trade count, net result, average outcome, losses and drawdown under consistent sizing and costs. Check whether the conclusion depends on one exceptional trade or one market episode. There is no universal trade count that converts a backtest into proof. Our probability and expectancy guide explains why win rate alone cannot describe the result.
Save the EA version or manual rule sheet, inputs, data provenance, cost assumptions, trade ledger and diagnostic notes together. For automated runs, MT4 provides result tabs and an HTML Save as Report option. Keep the Journal as well, especially when investigating missing trades or rejected operations.
Finish with a decision tied to the evidence: clarify an ambiguous rule, repair a data problem, reject the current version, or continue observing it on a demo account under frozen rules. Further testing should resolve a specific uncertainty. The framework for reviewing a strategy before changing systems helps distinguish a planned revision from a reaction to the latest loss.
Sources and related guidance
- MetaQuotes: MT4 tester controls and historical modelling methods.
- MetaQuotes: History Center and test results and report export.
- MQL4 Reference: tester execution limits and symbol properties.
- Continue with the site's MetaTrader guides and trading psychology and testing guides.
Documentation checked: 13 October 2026. Worked examples are hypothetical and do not represent a tested trading strategy.
No comments