How to Backtest an MT5 EA: Complete 2026 Guide for Gold & Forex EAs
Contents
- What Is a Backtest?
- Step 1: Open the Strategy Tester
- Step 2: Configure the Settings
- Select the EA
- Select the Symbol
- Select the Timeframe
- Select the Model
- Set the Date Range
- Set the Initial Deposit
- Set the Leverage
- Spread
- Step 3: Set EA Parameters
- Step 4: Run the Backtest
- Step 5: Read the Results
- The Graph Tab
- Key Metrics to Evaluate
- Step 6: Verify Out-of-Sample Performance
- Common Mistakes to Avoid
- Further Reading
How to Backtest an MT5 EA: Complete 2026 Guide
Before you run any Expert Advisor on a live account, you should backtest it. This is not optional. A backtest shows you how the EA would have performed on historical price data — including the drawdowns, losing streaks, and quiet periods that a simple demo run might miss.
This guide walks through the complete process using the MT5 Strategy Tester, from opening the tool to understanding the results.
What Is a Backtest?
A backtest simulates an EA's trading activity on historical price data. The MT5 Strategy Tester replays past price movements tick by tick and records every trade the EA would have made. At the end, you get a detailed report: total profit, maximum drawdown, profit factor, number of trades, and more.
Backtesting is not a guarantee of future performance. Markets change, and past results do not always repeat. But a well-run backtest on 5+ years of data gives you a reasonable expectation of how the EA behaves across different market conditions — trending markets, ranging markets, high-volatility events, and quiet periods.
Step 1: Open the Strategy Tester
In MT5, press Ctrl+R or go to View → Strategy Tester. The Strategy Tester panel will appear, usually docked at the bottom of the screen.
Step 2: Configure the Settings
This is the most important step. Incorrect settings will give you unreliable results.
Select the EA
In the top-left dropdown, select Expert Advisor. Then choose your EA from the list. If the EA does not appear, make sure the .ex5 file is in the correct folder: MQL5/Experts/ inside your MT5 data folder (open it with File → Open Data Folder).
Select the Symbol
Choose the currency pair or instrument you want to test. For gold:
- XM Trading users: select
GOLD(not XAUUSD — XM uses a different symbol name) - Exness / HFM users: select
XAUUSD
Using the wrong symbol name will result in zero trades or an error.
Select the Timeframe
Match the timeframe to the EA's designed timeframe. For example, if an EA is built for H1, test it on H1. Running an H1 EA on M5 will produce misleading results.
Select the Model
Always use Every Tick (based on real ticks). This is the most accurate simulation mode and uses actual tick data downloaded from the broker's server. The other options — "OHLC on M1" or "Open prices only" — are faster but less accurate and can produce inflated results.
Set the Date Range
Use at least 5 years of data. A shorter period may catch only favorable market conditions and miss the drawdown periods. We recommend:
- Minimum: January 2020 – December 2024 (5 years)
- Preferred: January 2019 – December 2024 (6 years, includes COVID volatility)
If you need to download historical data first, right-click the symbol in MT5's Market Watch and select Specification → Download Data.
Set the Initial Deposit
Use $10,000 as the starting balance. This is the standard we use across all EA backtests on this site, which makes results directly comparable between EAs.
Set the Leverage
Match the leverage to what your broker offers. A common setting is 1:200 or 1:500 for gold accounts. Leverage affects margin calculations but does not change the underlying profit/loss if you are using the RiskPercent parameter to control lot size.
Spread
If you leave this set to "Current spread," MT5 will use the spread at the moment you run the test — which may be unusually tight or wide. For more realistic results, enter a fixed spread that reflects typical trading conditions:
- XAUUSD/GOLD: 20–30 points (on standard accounts)
- XAUUSD on ECN accounts: 5–15 points
Step 3: Set EA Parameters
Click the Input parameters tab. Set the parameters as you intend to use them in live trading. The most important parameter for consistent testing is:
RiskPercent: Set to 1.0 (1% risk per trade) as a standardUseFixedLot: Set to false (let the EA calculate lot size based on risk %)UseCompounding: Set to true (reinvest profits as the balance grows)
If you are comparing different EAs, use the same parameter settings across all tests.
Step 4: Run the Backtest
Click Start. The progress bar at the bottom shows completion. For a 5-year backtest on gold with Every Tick model, expect it to take 10–60 minutes depending on your computer's speed and how much historical tick data needs to be processed.
Do not use your computer heavily during the test — it will slow down the simulation.
Step 5: Read the Results
When the backtest completes, three tabs appear: Results, Graph, and Report.
The Graph Tab
This shows the equity curve — how your account balance changed over time. A healthy equity curve climbs gradually with occasional pullbacks. Red flags include:
- A flat line followed by a sudden spike (curve fitting)
- A smooth curve with no drawdowns (too good to be true)
- A steep decline in the most recent period (strategy stopped working)
Key Metrics to Evaluate
Profit Factor (PF) Total gross profit divided by total gross loss. The most important single number.
| Profit Factor | Interpretation |
|---|---|
| Below 1.0 | Losing strategy — do not use |
| 1.0–1.3 | Marginal — needs more validation |
| 1.3–1.8 | Solid — acceptable for live trading |
| 1.8–2.5 | Very good — verify with out-of-sample test |
| Above 2.5 | Suspicious — likely over-optimized to historical data |
Maximum Drawdown The largest peak-to-trough decline during the test period. If you cannot tolerate watching your account fall by this amount, the EA is not right for you. A max drawdown above 20% indicates elevated risk.
Total Trades Fewer than 100 trades over 5 years makes the results statistically unreliable — you cannot tell if the EA is actually good or just got lucky on a few trades.
Expected Payoff Average profit per trade. Should be positive.
Recovery Factor Total net profit divided by maximum drawdown. A value above 3 is considered strong.
Step 6: Verify Out-of-Sample Performance
A proper backtest does not just run the EA on the full 5-year period. It splits the data:
- In-sample (training): The first 60% of the data (e.g., 2019–2022). Use this to select parameters.
- Out-of-sample (test): The remaining 40% (e.g., 2022–2024). Run the EA with those parameters on this period without changing anything.
If the EA performs well on the in-sample period but poorly on the out-of-sample period, the parameters are over-fitted to history. All EAs published on fxea365.com pass this validation test.
Common Mistakes to Avoid
Using OHLC model instead of Every Tick This produces results up to 20–30% more optimistic than reality because it misses intrabar price movements and stop-loss hits.
Testing on too short a period A 6-month backtest is nearly useless. Markets go through cycles. You need at least 3–5 years to see how an EA handles both trending and ranging conditions.
Not checking the spread An EA that looks profitable at 0 spread may lose money at realistic spreads. Always test with realistic spread settings.
Ignoring drawdown A 40% annual return with 35% max drawdown is not "impressive" — it is dangerous. At that drawdown level, a slightly worse period could wipe out a significant portion of capital.
Further Reading
For a deeper look at how we evaluate EA results, see our backtest interpretation guide. To compare backtest results across all EAs on this site, see the EA Ranking page.
Related
2026-05-22
What Is a Good Profit Factor for an EA? (And When High PF Is a Red Flag)
2026-05-22
Best Free XAUUSD EA for MT5 in 2026 | Backtest-Verified Gold Trading Bots
2026-05-22
Gold EA Risk Management: How to Set Lot Size & Avoid Blowing Your Account
2026-05-22
Best MT5 Broker for EA Trading in 2026 | XM vs Exness vs HFM Compared
5-Day Email Course (Free)
Get one email a day covering the essentials of FX automated trading, how to read backtests correctly, and tips for choosing a broker.
* Privacy strictly protected. You can unsubscribe at any time.