πRunning Optimizations
Executing Parameter Optimization
Now that you understand optimization fundamentals, this guide walks you through the practical steps of running an optimization in MT4 Strategy Tester.
Goal: Systematically test multiple parameter combinations to find optimal EA settings for your symbol and timeframe.
Quick Start: Running Your First Optimization
5-Step Process
Open Strategy Tester β Press
Ctrl+REnable Optimization β Check "Optimization" checkbox
Configure Parameters β Set ranges (Start, Step, Stop) in Inputs tab
Select Criteria β Choose optimization metric (Profit Factor recommended)
Click Start β Begin optimization run
Step-by-Step Optimization Setup
Step 1: Basic Configuration
Open Strategy Tester and configure standard settings:
Settings Tab:
In-Sample Data: Use only 60-70% of your data for optimization. Reserve remaining 30-40% for out-of-sample validation.
Step 2: Enable Optimization
Settings Tab:
β Check "Optimization" checkbox
β Uncheck "Visual mode" (disabled automatically)
What Changes:
Inputs tab shows parameter range controls
Optimization tab becomes active
MT4 will test multiple parameter combinations
Step 3: Configure Parameter Ranges
Inputs Tab Interface:
When optimization is enabled, each parameter shows:
Value: Current/default value
Start: Beginning of range
Step: Increment size
Stop: End of range
Checkbox: Enable optimization for this parameter (Y/N)
Example Configuration:
Optimization Enabled (β):
RiskPercent: Tests 1.0, 1.5, 2.0, 2.5, 3.0 (5 values)
BuyBuffer: Tests 3, 4, 5, 6, 7, 8, 9, 10 (8 values)
SellBuffer: Tests 3, 4, 5, 6, 7, 8, 9, 10 (8 values)
Total Iterations: 5 Γ 8 Γ 8 = 320 passes
Iteration Explosion: Each optimized parameter multiplies total passes. Optimize only 2-3 parameters to keep runtime manageable.
Setting Parameter Ranges
Rule of Thumb: Choose Meaningful Ranges
Too Narrow (wastes opportunity):
Too Wide (wastes time, risks over-fitting):
Just Right (explores meaningful range):
BananaEA Recommended Ranges
Risk Management Parameters
RiskPercent (Risk per trade):
MaxOpenTrades (Position limit):
Entry/Exit Parameters
BuyBuffer (Pips above signal):
SellBuffer (Pips below signal):
CandleRangeSL (Stop loss candle count):
CandleRangeTP (Take profit candle count):
Trade Management Parameters
BreakEvenMethod (Break-even strategy):
TrailingMethod (Trailing stop type):
Calculating Total Iterations
Formula: Multiply the number of values for each optimized parameter.
Example 1 - Conservative (2 parameters):
Example 2 - Standard (3 parameters):
Example 3 - Aggressive (5 parameters - NOT recommended):
Over-Optimization Alert: 1,000+ passes increases curve-fitting risk. Keep iterations under 500 for robust results.
Step 4: Select Optimization Criteria
Optimization Tab (becomes active when optimization enabled)
Available Criteria:
Balance Max (Default)
Optimizes for maximum net profit
Risk: May accept huge drawdowns
Profit Factor (Recommended)
Optimizes for best profit/loss ratio
Balanced risk/reward approach
Formula: Gross Profit Γ· Gross Loss
Expected Payoff
Optimizes for average profit per trade
Good for consistent performance
Balance Drawdown Max
Optimizes for maximum balance with lowest drawdown
Conservative, capital preservation focused
Custom
Use custom optimization criterion (requires coding)
BananaEA Recommendation: Use Profit Factor for most optimizations. It balances profitability with risk management better than raw profit.
Step 5: Advanced Optimization Settings
Genetic Algorithm vs. Slow Complete Algorithm
Optimization Tab Options:
Slow Complete Algorithm (Brute Force):
Tests EVERY parameter combination
Guaranteed to find global optimum
Use for: 2-3 parameters, <1,000 iterations
Genetic Algorithm (Evolutionary):
Tests random combinations, evolves best performers
Much faster but may miss global optimum
Use for: 4+ parameters, >1,000 iterations
BananaEA Recommendation:
2-3 parameters: Slow Complete Algorithm (thorough)
4+ parameters: Genetic Algorithm (speed)
Other Settings
Use Local Agents (if available):
Distributes optimization across multiple CPU cores
Significantly faster for large optimizations
Check this if your computer has 4+ cores
Forward Test Validation:
MT4 can automatically validate on forward period
Useful but not replacement for manual out-of-sample testing
Step 6: Start Optimization
Click [Start] Button
What Happens:
Monitoring Optimization Progress
Progress Indicators
Status Bar (Bottom of Strategy Tester):
Information Displayed:
Current Pass: Which iteration (e.g., 145/320)
Percentage: Completion progress (45%)
Estimated Time: Time remaining (if available)
Journal Tab: Shows progress messages:
Typical Optimization Durations
Quick Optimization (50-100 passes, 2 years, Open Prices):
Time: 10-30 minutes
Use: Quick parameter screening
Standard Optimization (200-500 passes, 2 years, Open Prices):
Time: 1-2 hours
Use: Regular optimization runs
Large Optimization (1,000-2,000 passes, 3 years, Open Prices):
Time: 3-8 hours
Use: Comprehensive parameter search
Massive Optimization (5,000+ passes, 5 years, Every Tick):
Time: 24-72+ hours
Use: Professional validation (use cloud optimization)
Speed Tip: Use "Open Prices Only" for optimization. It's 10-50x faster than "Every Tick" while still providing meaningful results for parameter comparison.
Optimization Results
Results Table
After completion, Optimization Results tab shows ranked parameter combinations:
Columns:
Pass: Optimization iteration number
Result: Value of optimization criterion (Profit Factor, Net Profit, etc.)
Profit: Total net profit
Trades: Number of trades executed
PF: Profit Factor (Gross Profit / Gross Loss)
DD: Maximum Drawdown percentage
Parameter Values: Shows values used for each optimized parameter
β = Best Result based on selected criterion
Analyzing Top Results
NEVER just pick #1!
Professional Approach:
Review Top 10-20 Results (not just best)
Look for Consistency:
Do top results cluster around similar parameter values?
Or are they wildly different?
Check for Red Flags:
Outliers (one amazing result, rest mediocre)
Extreme parameters (BuyBuffer=23.7 pips)
Too-good-to-be-true metrics (100% win rate)
Prefer Robust Results:
Top 5 results have similar parameters
Smooth performance across parameter ranges
Reasonable metrics (not extreme)
Example - Robust Optimization:
Example - Suspicious Optimization:
Saving Optimization Results
Export Results Table
Right-click in Optimization Results tab:
Save as Report: Exports to HTML file
Choose filename and location
Includes full results table with all parameters
Recommended Filename:
Why Save:
Compare optimizations over time
Track what you've tried
Reference for future re-optimization
Documentation for strategy development
Creating Preset Files
Once you've identified optimal parameters:
Create .set File:
Strategy Tester β Inputs tab
Manually enter optimal parameter values
Right-click in inputs area
Select "Save"
Name file:
BananaEA-DAX-H1-Optimized-Oct2025.setSave in:
MQL4/Presets/folder
Benefits:
Quick loading of optimal settings
Easy comparison between parameter sets
Sharing optimized configurations
Deployment to live trading
Out-of-Sample Validation (Critical!)
MANDATORY: Never use optimized parameters without out-of-sample validation!
Validation Process
Step 1: Run Standard Backtest on Out-of-Sample Data
Step 2: Compare In-Sample vs. Out-of-Sample Performance
Good Result (Robust optimization):
Bad Result (Over-fitted):
Critical Rule: If out-of-sample performance degrades significantly (>30% drop in Profit Factor or turns negative), parameters are over-fitted. DO NOT USE. Re-optimize with fewer parameters or wider ranges.
Troubleshooting Optimization Issues
Issue 1: Optimization Taking Too Long
Problem: Optimization running for 10+ hours
Solutions:
β Reduce parameter ranges (fewer values)
β Use larger step sizes (skip intermediate values)
β Reduce test period (2 years instead of 5)
β Enable "Use Local Agents" (multi-core processing)
β Switch to Genetic Algorithm (if 1,000+ passes)
Issue 2: All Results Nearly Identical
Problem: Top 100 passes have almost same performance
Cause: Parameters have little impact or ranges too narrow
Solutions:
Widen parameter ranges
Optimize different parameters (more impactful ones)
Check if EA is actually using the parameters
Verify sufficient trades executed (not just 5-10 trades)
Issue 3: Best Result is Outlier
Problem: Pass #1 is amazing, Pass #2-100 are mediocre
Cause: Curve fitting to specific historical anomaly
Solutions:
Ignore the outlier (it's over-fitted)
Use parameters from Pass #5-10 (more robust)
Look for clustering in top results
Re-optimize with fewer parameters or coarser steps
Issue 4: Optimization Crashes
Problem: MT4 crashes mid-optimization
Solutions:
Update MT4 to latest version
Close other programs (free RAM)
Reduce test period or iteration count
Check EA code for memory leaks
Try different computer if persistent
Next Steps
Now that you can run optimizations:
Analyze Results Deeply β Analyzing Results
Learn Advanced Techniques β Advanced Optimization
Validate Properly β Validation & Forward Testing
Follow Best Practices β Best Practices & Tips
Professional Tip: Document every optimization. Keep a spreadsheet with date, parameters optimized, ranges used, in-sample results, out-of-sample results, and final decision. This becomes your optimization history and learning log!
Related Resources
Optimization Fundamentals - Theory and concepts
Analyzing Results - Understanding your data
Best Practices & Tips - Professional workflow
Advanced Optimization - Walk-forward, Monte Carlo
Last updated