Backtesting guide
MT4 backtesting: set up a reproducible Expert Advisor test
MT4 Strategy Tester evaluates an Expert Advisor against historical data and simulated execution. A useful test records the exact EA, data and assumptions so another run can reproduce it. A profitable report describes that simulation; it does not establish the fills or returns available at a live broker.
Read the practical guideKey Takeaways
- MT4 modes are Open prices only, Control points and Every tick. One minute OHLC is an MT5 mode.
- Built-in Every tick generates an intrabar path from available lower-timeframe bars; its name does not mean recorded historical ticks.
- Save one baseline with fixed inputs before searching parameter combinations.
- Generate and review MQL4 separately from running the test in your MT4 terminal.
Record the experiment before pressing Start
Compile the EA in MetaEditor and select it in Strategy Tester. Set the symbol, timeframe, date range, deposit, allowed direction, input values and spread. Disable Optimization for a single baseline. Save the source version and input set with a screenshot of those settings.
- Write the intended signal time, order type, sizing, stop, target and overnight policy in plain language. Use this specification to check the generated EA.
- Record broker/server, terminal build, history source, timezone and symbol specification. Similar symbol names can have different contract sizes or price precision.
- Check that the requested historical window is actually covered. A date entered in a field is not evidence that all required bars exist.
Choose a model that can represent the rule
Open prices only is intended for completed-bar systems; Control points provides a rough estimate. Every tick interpolates between lower-timeframe OHLC control points. Inspect history coverage and the report quality band. There is no universal 99%, 90% or 25% accuracy assigned to these menu choices.
- If a rule depends on the sequence of touches inside a bar, check representative trades visually and compare model sensitivity. More generated events cannot recover an unknown real tick sequence.
- A change of model can increase or decrease profit. Trace the first differing signal or fill instead of assuming a fixed percentage inflation.
- Reading the current bar is not automatically look-ahead bias. Using its eventual high, low or close before those values were available is the relevant timing failure.
Make spread and contract units explicit
MT4 history contains Bid prices; the standard tester derives Ask from the current starting spread or the custom spread selected for the test. This does not establish a historical variable-spread record. Run separately labeled spread scenarios and reconcile an example trade by hand.
- Spread is expressed in points. For a hypothetical five-decimal EURUSD quote with Point = 0.00001, 20 points equal 0.00020, conventionally two pips. Confirm the actual symbol rather than applying that conversion to every instrument.
- Inspect lot size, tick value, tick size, minimum volume, volume step, stop distance and swap calculation method. Contract settings determine what a price move means in account currency.
- Verify which commission and overnight charges actually appear in the run. Reconcile missing costs separately and label the adjustment; do not assume a universal fee field or historical swap schedule.
- Treat slippage, delayed orders and rejected orders as separate execution questions. A modeling-quality score is not a broker execution guarantee.
Check code behavior that the tester cannot reproduce
MQL4 documents tester restrictions: WebRequest and external notifications do not execute, Timer events are not handled, and trade operations on symbols other than the tested symbol are unavailable. An EA that depends on these behaviors needs a separate test design.
- For a news-driven rule, preserve a historical input file with availability timestamps. A current API response cannot stand in for information known years earlier.
- Check initialization, rejected orders and runtime messages in Journal. An empty trade list may be an execution error rather than a rule that found no opportunity.
- Inspect a small set of known decisions against the specification before interpreting aggregate profit. Compilation alone does not verify those decisions.
Separate optimization from evaluation
MT4 optimization varies checked inputs using Start, Step and Stop ranges and ranks the runs by a chosen objective. Save the full search settings and all candidates, not only the winner. The highest result in a search is selected evidence, not an independent estimate of future performance.
- Choose a later evaluation period before selecting parameters. Keep it untouched until the candidate and cost assumptions are frozen.
- For a poor result, investigate the cause before adding another filter. A new filter is another tried strategy and belongs in the experiment log.
- Observe the frozen version on a demo account and compare signals, submission times and fills. Demo execution still differs from live conditions.
- Set observation and stopping criteria from the strategy cadence and risk question. Neither a fixed trade count nor three months of demo activity certifies a strategy.
Related Pineify workflow
Prepare an MQL4 EA for your own terminal
Describe the rules and request an MQL4 implementation in Pineify, then inspect the source and compile it in MetaEditor.
Choose MQL4 and specify entry timing, order handling and risk limits.
Draft the MQL4 logicBoundary: Code generation and syntax checking do not run the historical experiment or validate its returns. Keep the MT4 test settings, report and execution review separately.
Primary sources
- MetaTrader 4: Strategy Tester setup and modelingVerified 2026-10-20
- MQL4: Program behavior in the testerVerified 2026-10-20
- MQL4: Symbol properties and unitsVerified 2026-10-20
- MetaTrader 4: Optimization setupVerified 2026-10-20
This page is educational and does not provide investment advice. Backtests are hypothetical, depend on their data and assumptions, and do not guarantee future results. Trading can result in substantial loss.