Summary: Many EAs fail in live trading because of curve fitting. This guide explains how to avoid over-optimization, use out-of-sample data, and set realistic backtest parameters in MT5.




Step 1: Understand What Curve Fitting Means

Curve fitting happens when you adjust your EA‘s parameters to perfectly match historical data. The EA learns the ‘noise’ instead of the actual market pattern. As a result, it performs well in backtests but fails in live trading [citation:5]. Screenshot: Backtest report showing perfect equity curve vs live trading loss chart.

Step 2: Split Your Historical Data

Never use the same data for optimization and validation. Split your data into two periods. For example, use 2019-2023 for parameter optimization and 2024-2025 for out-of-sample testing [citation:5]. Screenshot: MT5 Strategy Tester with date range selection highlighted.

Step 3: Use Multiple Optimization Goals

Do not just chase the highest ‘Net Profit’. In MT5 Strategy Tester, set optimization goals to multiple metrics: Profit Factor, Sharpe Ratio, Maximum Drawdown, and Recovery Factor [citation:5]. A balanced EA is better than a ‘perfect’ one. Screenshot: MT5 optimization settings showing multiple target criteria.

Step 4: Check Parameter Stability

After running a genetic algorithm optimization, look at the top 10-20 result sets. If the best parameters (e.g., RSI period or moving average length) are completely different from the 2nd or 3rd best, the optimization is unstable [citation:5]. A robust EA will have a ‘plateau’ where similar parameters produce similar results. Screenshot: Optimization results table showing parameter clustering.

Step 5: Test with Realistic Market Conditions

Enable ‘Variable Spread’ and set a realistic ‘Slippage’ value (e.g., 2-3 points) in the backtest settings. Also select ‘Every Tick’ as the modeling method [citation:5]. Using fixed spreads and zero slippage creates overly optimistic results. Screenshot: Backtest settings with Variable Spread and Every Tick options checked.

Step 6: Validate on Out-of-Sample Data

After finding a promising parameter set, run the backtest on your reserved out-of-sample data (e.g., 2024-2025) WITHOUT changing any parameters. If performance drops significantly (e.g., drawdown doubles), your EA is likely curve-fitted [citation:5]. Screenshot: Out-of-sample backtest report showing performance drop.

Step 7: Run Forward Testing on a Demo Account

Finally, let the EA run on a demo account for at least 2-4 weeks with real-time market data. This confirms that the EA works in a live environment with real spreads, slippage, and execution delays. Screenshot: Demo account statement showing EA performance.

Reference: MetaQuotes MQL5 Documentation; CSDN EA Optimization Guide (February 2026) [citation:5].