πŸš€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.

circle-check

Quick Start: Running Your First Optimization

5-Step Process

  1. Open Strategy Tester β†’ Press Ctrl+R

  2. Enable Optimization β†’ Check "Optimization" checkbox

  3. Configure Parameters β†’ Set ranges (Start, Step, Stop) in Inputs tab

  4. Select Criteria β†’ Choose optimization metric (Profit Factor recommended)

  5. Click Start β†’ Begin optimization run


Step-by-Step Optimization Setup

Step 1: Basic Configuration

Open Strategy Tester and configure standard settings:

Settings Tab:

circle-info

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

circle-exclamation

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):


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):

triangle-exclamation

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)

circle-check

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)

circle-info

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:

  1. Review Top 10-20 Results (not just best)

  2. Look for Consistency:

    • Do top results cluster around similar parameter values?

    • Or are they wildly different?

  3. 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)

  4. 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:

  1. Strategy Tester β†’ Inputs tab

  2. Manually enter optimal parameter values

  3. Right-click in inputs area

  4. Select "Save"

  5. Name file: BananaEA-DAX-H1-Optimized-Oct2025.set

  6. Save 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):

triangle-exclamation

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:

  1. Analyze Results Deeply β†’ Analyzing Results

  2. Learn Advanced Techniques β†’ Advanced Optimization

  3. Validate Properly β†’ Validation & Forward Testing

  4. Follow Best Practices β†’ Best Practices & Tips

circle-check

Last updated