Summary: Over-optimized EAs fail in live trading. This guide shows how to use MT4 Strategy Tester’s optimization feature correctly: split data, avoid curve fitting, and validate real performance.
Step 1: Open Strategy Tester in MT4
Click ‘View’ → ‘Strategy Tester’ or press Ctrl+R. The tester panel appears below your charts. Screenshot: Strategy Tester panel at the bottom of MT4.
Step 2: Select Your EA and Symbol
In the tester panel, choose your EA from the ‘Expert Advisor’ dropdown. Select a currency pair (e.g., EURUSD) and set timeframes to ‘Every tick’ for accuracy. Screenshot: EA and symbol selection area.
Step 3: Choose Optimization Mode
Click ‘Expert Properties’ (or the settings button). Go to ‘Optimization’ tab. Check ‘Optimization’ box. Uncheck ‘Visual mode’ – it slows down optimization. Screenshot: Optimization tab with checkbox enabled.
Step 4: Set Input Parameter Ranges
In the ‘Inputs’ tab, click on any parameter you want to optimize (e.g., TakeProfit). Check ‘Optimize’ box for that parameter. Set ‘From’, ‘Step’, and ‘To’ values. Example: From 20, Step 5, To 50 – tests 20,25,30,35,40,45,50. Screenshot: parameter range settings.
Step 5: Split Data into In-Sample and Out-of-Sample
Use the ‘Date’ range in the tester. First run optimization on ‘In-Sample’ period (e.g., 2023.01.01 – 2023.06.30). Note the best parameters. Then test those same parameters on ‘Out-of-Sample’ period (e.g., 2023.07.01 – 2023.12.31) without re-optimizing. Screenshot: date range settings.
Step 6: Start Optimization and Analyze Results
Click ‘Start’. Wait for completion. Go to ‘Optimization Results’ tab. Sort by ‘Total net profit’ or ‘Sharpe ratio’. The best set appears at the top. Screenshot: optimization results list sorted by profit.
Step 7: Validate on Out-of-Sample Data
Take the top 3 parameter sets from step 6. Run single backtests on the Out-of-Sample period using each set. If performance drops significantly (e.g., profit turns negative), your EA is curve-fitted – discard it. If performance remains positive and stable, the EA is robust. Screenshot: out-of-sample backtest result.
Reference: MetaQuotes Help – Strategy Tester Optimization Tips.