Home/Blog/Testing
Testing2024-12-0512 min read

How to Properly Backtest Your Expert Advisor (Avoid These 7 Mistakes)

Why Backtesting Matters

Backtesting is your EA's first real test. It simulates how your strategy would have performed on historical data. But here's the problem: most traders backtest incorrectly and get results that don't translate to live trading.

A properly backtested EA should give you:

  • Realistic expectation of profitability
  • Understanding of drawdown characteristics
  • Confidence in various market conditions
  • Data to optimize without overfitting
  • The harsh truth: An EA that shows 500% returns in backtesting might lose money in live trading if the test was flawed.

    The 7 Critical Mistakes

    Mistake 1: Using Low-Quality Data

    Most traders use the default data from their broker, which has gaps, incorrect prices, and missing ticks. This is like testing a race car on a broken track.

    Solution: Use 99% modeling quality tick data from providers like Dukascopy or TrueFX. For MT5, download real tick data from your broker.

    Mistake 2: Ignoring Spread Variations

    Fixed spreads in backtests don't reflect reality. Spreads widen during news, Asian sessions, and low liquidity periods.

    Solution: Use variable spread simulation or add a spread buffer (e.g., if average spread is 1.2 pips, test with 1.8 pips).

    Mistake 3: Not Accounting for Slippage

    In live trading, you rarely get the exact price you requested. Slippage can be 0.5-3 pips on average, more during volatility.

    Solution: Add slippage simulation of at least 1 pip for major pairs, 2-3 pips for exotic pairs.

    Data Quality

    What Good Data Looks Like

  • Modeling quality: 99% or higher
  • Mismatched charts errors: Zero
  • Tick data: Real ticks, not interpolated
  • Time coverage: At least 5 years for swing strategies, 2 years for scalpers
  • How to Check Data Quality

    `` In MT4/MT5 Strategy Tester:
  • 1. Run a test
  • 2. Check the "Report" tab
  • 3. Look for "Modeling quality" percentage
  • 4. Look for "Mismatched charts errors"
  • ``

    Red flags:

  • Modeling quality below 90%
  • Any mismatched charts errors
  • Gaps in the data (visible in chart)
  • Suspicious price spikes
  • Spread and Slippage

    Realistic Spread Settings

    | Pair | Average Spread | Test With | |------|---------------|-----------| | EURUSD | 0.8-1.2 pips | 1.5-2.0 pips | | GBPUSD | 1.0-1.5 pips | 2.0-2.5 pips | | USDJPY | 0.8-1.2 pips | 1.5-2.0 pips | | XAUUSD | 20-35 cents | 40-50 cents |

    Slippage in Code

    ``mql4 // Add slippage to your OrderSend int slippage = 30; // 3 pips for 5-digit broker ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage, sl, tp); ``

    Pro tip: Run the same backtest with different spread/slippage settings. If your profits disappear with slightly higher costs, your edge is too thin.

    Walk-Forward Analysis

    Walk-forward analysis is the gold standard for validating EA performance. It prevents curve-fitting by testing on data the optimizer never saw.

    How It Works

  • 1. Optimize on Period 1 (e.g., Jan 2020 - Dec 2020)
  • 2. Test best parameters on Period 2 (Jan 2021 - Mar 2021)
  • 3. Optimize on Period 2 (Jan 2021 - Dec 2021)
  • 4. Test on Period 3 (Jan 2022 - Mar 2022)
  • 5. Repeat...
  • What Good Results Look Like

  • Out-of-sample periods are profitable (not just in-sample)
  • Performance is consistent across periods
  • Drawdowns are similar in-sample and out-of-sample
  • No dramatic parameter changes between periods
  • If your EA only works on optimized periods, it's curve-fitted and will fail live.

    Statistical Significance

    How Many Trades Do You Need?

    A backtest with 50 trades is statistically meaningless. Here's the minimum:

    | Confidence Level | Minimum Trades | |-----------------|----------------| | Low confidence | 100 trades | | Medium confidence | 300 trades | | High confidence | 500+ trades |

    Key Metrics to Evaluate

  • Profit Factor: Should be > 1.3 (ideally > 1.5)
  • Sharpe Ratio: Should be > 1.0 (ideally > 2.0)
  • Maximum Drawdown: Should be < 30% of total profit
  • Recovery Factor: Should be > 3.0
  • Win Rate vs R:R: Must make mathematical sense
  • The Monte Carlo Test

    Run 1,000 simulations with randomized trade order to see:

  • Best case scenario
  • Worst case scenario
  • Most likely outcome
  • Probability of ruin
  • Use our Monte Carlo Calculator to test your strategy parameters.

    Conclusion

    Proper backtesting is hard work, but it separates professional EA developers from gamblers. Follow these principles:

  • 1. Use quality data - 99% modeling quality minimum
  • 2. Add realistic costs - Spread buffers and slippage
  • 3. Walk-forward test - Validate on unseen data
  • 4. Ensure significance - 300+ trades minimum
  • 5. Monte Carlo simulate - Understand your risk of ruin
  • 6. Forward test - Run on demo before going live
  • 7. Start small - Even after all tests, start with micro lots
  • Remember: A smaller, verified edge is worth more than a big, unverified one.

    Need help validating your EA? Get a free strategy audit or use our profitability calculator to stress-test your parameters.

    🧑‍💻

    TradeMetrics Pro Team

    Expert EA developers with 10+ years of experience in automated trading systems.

    Need Help With Your EA Project?

    Get expert assistance with strategy conversion, EA development, or optimization.