What is backtesting in forex?
Definition Backtesting is running a trading strategy's rules on historical price data to see how it would have traded in the past, including its trades, losing streaks and drawdown, before it is used on live prices.
Backtesting in forex means running a strategy’s rules on historical prices to see what it would have done: which trades it would have taken, how long its losing streaks were and how deep its drawdown went. In MetaTrader 5, it is done in the Strategy Tester, which feeds price history through an Expert Advisor as if the market were live.
How to run a backtest in MT5
- Press Ctrl+R to open the Strategy Tester, or right-click the EA in the Navigator and choose Test.
- Choose the EA, the symbol, the timeframe and the date range.
- Pick a modelling mode, the deposit and the leverage.
- Set the execution delay. With no delay, every order fills at the requested price without requotes; the random and fixed delays simulate slower execution (MT5 help).
- Click Start and read the report.
Modelling modes
The mode decides which prices the EA sees inside each bar (MT5 help: tick generation):
| Mode | What the tester feeds the EA | Trade-off |
|---|---|---|
| Every tick based on real ticks | The broker’s recorded ticks; generated ticks for minute bars without them | Closest to real conditions |
| Every tick | Ticks generated from the bars’ open, high, low and close | The most accurate generated mode, and the slowest |
| 1 minute OHLC | Four prices per minute bar | Faster; misses the path inside each minute |
| Open prices only | The open of each bar on the tested timeframe | Fastest; stops and pending orders may fill at a different price |
| Math calculations | No prices | For calculations, not trading |
The spread is not simulated: the tester takes it from the historical data and treats it as floating (testing features).
Worked example: small costs, large gap
Costs are one reason backtests flatter. Others:
- Fitting. Tuning inputs on the same history until the curve looks smooth (overfitting). MT5’s Forward setting keeps 1/2, 1/3, 1/4 or a custom part of the period for a separate test, which MetaQuotes says is there “to avoid fitting to certain time intervals” (MT5 help).
- Coarse modes. On “Open prices only”, stops and pending orders may fill at a price other than the one set.
- What history leaves out. Your own outages, and the delays of live execution unless you simulate them.
The common mistake is reading the net result as a forecast. A backtest is more useful for behaviour: how often the EA trades, its longest losing streak and its deepest drawdown. The drawdown calculator shows what a drawdown of that size takes to recover. The next step is a forward test on live prices: how to test an EA on a demo account.
Backtesting and PipWarden
PipWarden’s EA does not run in MT5’s Strategy Tester, because it needs WebRequest, which the tester does not allow. The dashboard has its own backtest instead. It replays the same strategy and your risk settings, bar by bar, on price history collected from your own broker’s feed. Buys fill at the ask and sells at the bid, a bar that touches both stop and target counts as a stop, and the daily loss limit, position caps, spread limit and free-margin check apply as they do live. It lists how many signals the rules stopped and why.
It does not model swaps, the optional AI filter or the news blackout, because no historical news calendar is stored. Its results describe the past and are not a forecast. The details are on the features page.
Frequently asked questions
Which Strategy Tester mode is the most accurate?
Does a good backtest mean an EA will do well live?
Educational content, not financial advice. Forex and CFDs are traded on margin and are high risk: you can lose money, and more than your deposit with some brokers. Examples use made-up numbers and show no real results. Read the risk disclosure.