Testing & Risk tutorial

How to Run a Strategy Backtest in MT5

Run an EA over historical data in the MetaTrader 5 Strategy Tester, with settings that resemble your real account, and read the results without fooling yourself.

Intermediate About 30 min(estimate) 9 stepsUpdated

Times are estimates — they vary with your computer, connection and experience.

Before you start

  • MetaTrader 5 with the EA installed — see How to Install an Expert Advisor in MT5.
  • The EA's recommended symbol, timeframe and .set file.
  • Time for the tester to download history the first time (it can take a while for long periods).

What you'll learn

  • Configure a backtest that resembles your real trading conditions.
  • Read the key statistics and the equity graph.
  • Recognise results that are too good to trust.

Steps

  1. Step 1: Open the Strategy Tester

    Choose View → Strategy Tester (Ctrl+R). The tester opens as a panel with several tabs, starting with Settings.

  2. Step 2: Choose the EA, symbol and timeframe

    Select your Expert Advisor, then the symbol and timeframe given in its documentation.

  3. Step 3: Set a meaningful date range

    Pick a custom period long enough to include different conditions — trends, ranges and volatile spells — rather than just the last few months. Leave Forward off for a first test.

  4. Step 4: Pick the modelling mode

    For EAs that act within a bar, choose Every tick based on real ticks when your broker provides tick history — the most detailed mode, and the one that uses recorded spreads. Open prices only is much faster but only valid for EAs that trade on a new bar.

  5. Step 5: Match your account

    Set Deposit and Leverage to what you'll actually trade with. Under Delays, choose a non-zero execution delay rather than ideal execution to make fills more realistic.

  6. Step 6: Load the inputs

    On the Inputs tab, right-click and load the developer's .set file or your own, and keep Optimization disabled for this run.

  7. Step 7: Start the test

    Click Start. When it finishes, open the Backtest tab for the report and the Graph tab for the balance and equity curves.

  8. Step 8: Read the report

    Look at these together, never profit alone:

    • Total net profit — meaningless without the drawdown beside it.
    • Maximum drawdown (balance and equity) — could you sit through it with real money?
    • Profit factor — gross profit ÷ gross loss.
    • Total trades — very few trades make every other number unreliable.
    • Largest loss trade — can a single trade do serious damage?
  9. Step 9: Check costs and the equity curve

    Scroll the deals in the report to confirm commission was charged if your broker charges it — if not, live results will be worse. On the graph, a smooth rising line with sudden deep drops often means grid or martingale risk.

    Don't run an optimisation and keep the single best result: those settings are usually fitted to past noise. Prefer settings that work reasonably across a range of values, and test them on a period you didn't optimise on.

Expected result

A completed report and graph for your EA on realistic settings, with the net profit read alongside maximum drawdown, trade count and costs — and a clear idea of whether it's worth a demo forward test.

Troubleshooting

"No history" or the test ends immediately
Let the tester download data and try again, or choose a period your broker has history for.
No trades at all
Check the Journal tab of the tester for errors, confirm the symbol name matches what the EA expects, and that its filters (spread, hours) can be met.
Results differ every time with real ticks
Random execution delays change fills slightly between runs. Use the same delay setting when comparing configurations.
Licensed EA won't run in the tester
WebRequest-based license checks can't run in the Strategy Tester. Check the developer's instructions for testing.

Official documentation

Next tutorial

How to Test a Forex Bot on a Demo Account

Forward test an Expert Advisor on a demo account: open a demo, mirror your real settings, keep a simple log and compare results with the backtest.

Continue

Related tutorials

All tutorials
  • Forex Bots & EAsIntermediate

    How to Configure Expert Advisor Settings

    Configure an Expert Advisor's inputs in MT4 or MT5: lot size and risk, stop-loss units, magic numbers and spread limits, plus saving and loading .set files.

    About 20 min(estimate) 7 steps
  • FXBotHub MarketplaceBeginner

    How to Evaluate a Forex Bot Before Purchasing

    Walk through a forex bot listing before you buy: quality signals, documentation, compatibility, changelog, verified reviews and questions for the seller.

    About 20 min(estimate) 8 steps