SwiftCap™ EAs
ProductsTrinity EARange PortfolioResultsFAQBlogAffiliateFree DownloadsContact
Customer loginExplore EAs →

Blog / Backtesting

How to backtest an EA in MT5 and trust the result.

A backtest is the cheapest way to find out how an Expert Advisor behaves before it touches your money. It is also easy to get wrong. A backtest that skips costs, uses poor data or covers a short, friendly period can make a weak EA look great. This guide shows how to run one in the MetaTrader 5 Strategy Tester, and how to read the results honestly.

1. Set up the Strategy Tester

Open the tester in MetaTrader 5 with Ctrl+R (or View → Strategy Tester). On the Settings tab:

  • Expert: pick the EA from your Experts folder.
  • Symbol and timeframe: use the chart the EA is designed for. A multi-market EA still needs one starting chart; its guide will tell you which.
  • Date: a custom range. More on how long below.
  • Delays: "Zero latency" is fine for a first look. A random delay is a useful stress test for EAs that trade fast-moving breakouts.
  • Deposit and leverage: match the account you plan to trade, so lot sizes and margin behave the same.

Open the Inputs tab and set the EA's risk the way you would trade it. For comparing EAs, a fixed cash risk per trade with no compounding is the clearest choice: every trade risks the same amount, so the equity curve shows the edge rather than the effect of growing position sizes.

2. Choose the right modelling mode

The Modelling setting decides how the tester rebuilds price movement inside each bar. It matters more than most people think.

ModeWhat it doesUse it for
Every tick based on real ticksReplays the broker's recorded ticks, with real spreadsThe final, most realistic check
Every tickGenerates ticks from 1-minute barsDetailed tests when real ticks are missing
1 minute OHLCUses only the open, high, low and close of each minuteFast, reasonable tests for EAs that don't depend on tick-level detail
Open prices onlyUses only the first price of each barQuick screening of EAs that act only at bar open

A good habit is to run the long test in a faster mode, then rerun it on real ticks and compare. If the results collapse, the EA depends on price detail the faster mode got wrong.

As an example, our Trinity EA backtest (2018 to October 2026, $100 risk per trade per system) made $66,370 with a profit factor of 1.52 on 1-minute OHLC. The real-tick rerun made $60,274 with a profit factor of 1.46. Lower, as you'd expect from real spreads and fills, but the same shape. That is what a robust result looks like.

The report's history quality figure tells you how complete the price data was. Low quality means gaps the tester filled in, so treat the result with more caution.

3. Include every cost

Costs are where most flattering backtests come from. There are three:

  • Spread. Real-tick mode uses the recorded spread. Other modes use the spread you set; "Current" can be unrealistically tight outside busy hours, so check it.
  • Commission. Raw-spread accounts charge a fee per lot. Depending on your broker, the tester may or may not apply it. Look for a commission line in the report; if it isn't there, account for it yourself.
  • Swap. Overnight financing applies to positions held past the daily rollover. It matters most for EAs that hold trades for days.

Commission adds up quickly on gold and forex. In the same Trinity backtest, commission at $3.50 per lot per side came to $4,512 over 645 lots. For the Range Portfolio, which trades far more often, it was $36,022. Leave that out and the results look better than any real account could achieve.

4. Test a long, varied period

An EA tuned on one quiet year tells you little. Test across years with very different conditions: trending and ranging markets, calm periods and volatile ones. Since 2018, markets have seen the 2020 pandemic crash, a rapid rise in interest rates and long stretches of both low and high volatility. That is the kind of variety a strategy should survive.

If you can, keep the most recent part of the history aside. Make all your decisions on the earlier data, then run the untouched period once. MetaTrader 5's Forward setting does this automatically during optimisation.

5. Read the report: the numbers that matter

Net profit is the least informative number on the page. Look at these instead:

  • Profit factor: gross profit divided by gross loss. Above 1 means the EA made money after costs. A believable long-run figure for a diversified, cost-included backtest is usually well below 2. Very high values often mean curve fitting.
  • Maximum drawdown in risk units: divide the drawdown by the risk per trade. Trinity's largest closed-trade drawdown was $1,744 at $100 risk, about 17 trades' worth of risk. That tells you how far a bad run went, whatever account size you trade.
  • Number of trades: a few dozen trades can be luck. Hundreds or thousands across several years are far more meaningful.
  • Consistency: how many months and years were profitable, and how bad was the worst month? Trinity's backtest had 93 profitable months out of 106; its worst was −$1,231 in September 2018.
  • Equity curve shape: a steady slope beats a curve made by a handful of huge wins.

6. Watch for curve fitting

Curve fitting means tuning an EA's inputs until they match the past perfectly. The backtest looks superb, and live trading disappoints. Warning signs:

  • Many inputs with oddly precise values, such as a 37-pip stop and an 83-minute filter.
  • Results that fall apart when you change an input slightly, the test period, or the modelling mode.
  • A short test period, or one that starts and ends at suspiciously convenient dates.
  • Grid or martingale logic, which produces smooth curves right up to the day it doesn't.

The best defence is to change one thing at a time and see whether the result still holds: a nearby input value, a different broker's data, a later period, real ticks. A real edge bends; an overfitted one breaks.

7. A quick checklist

  1. Several years of data, including volatile periods.
  2. Spread, commission and swap all included.
  3. A final rerun on real ticks, with results in the same range.
  4. Fixed risk per trade, no compounding, when comparing EAs.
  5. Drawdown measured in units of risk per trade.
  6. Hundreds of trades, not dozens.
  7. Stable results when inputs or periods change slightly.
  8. A demo or small live account before trusting it with more.
Every SwiftCap EA comes with a full backtest report (PDF) that follows these rules: 2018 onwards, costs included, fixed risk, with instructions for running the same test yourself. See the Trinity and Range Portfolio backtests.
SwiftCap Trinity EAFour gold systems on one chart, with a daily risk limit. Live Myfxbook account and full backtest. SwiftCap Range PortfolioTwelve session-breakout strategies across 10 markets, with prop-firm protection built in.

Risk notice. This article is for education only and is not financial advice. Trading involves substantial risk of loss. Backtested results are hypothetical and past or simulated performance does not guarantee future results.