Home → Other Contents → Backtesting and Optimization Procedures
Introduction
Getting an EA (Expert Advisor) and its set file doesn’t guarantee it will work as expected. That’s why backtesting—simulating trades using historical data—is essential to verify its logic and performance. To further enhance results, optimization helps fine-tune parameters for maximum profit and minimal risk.
This guide explains the purpose and steps of backtesting and optimization in MT5, with clear visuals and beginner-friendly instructions.
What is Backtesting?
Backtesting is a simulation that evaluates how an EA would have performed in past market conditions. It helps you understand the EA’s strategy, behavior, and risk management before using it in live trading.
Goals of Backtesting
- Profitability Check
- See if the EA generates profit based on historical price data. For example, a trend-following EA may struggle in ranging markets—this helps identify strengths and weaknesses.
- Trade Behavior Analysis
- Understand when the EA enters and exits trades, and how it reacts to different market conditions.
- Risk Evaluation
- Review metrics like maximum drawdown and consecutive losses to assess capital management.
How to Run Backtests in MT5
1. Load the EA

- Save the EA file (.ex5) into MQL5 → Experts folder
- Restart MT5 to see it appear in the Navigator window.
2. Open Strategy Tester
- Go to “View” → “Strategy Tester” (or press Ctrl+R)
- The Strategy Tester panel will appear at the bottom of the screen.
3. Configure Test Settings

a. Expert: Select the EA you want to test
b. Symbol: Choose the currency pair or instrument
c. Timeframe: Select the chart period
d. Date: Specify the start and end dates for testing
e. Delays: Set the execution delay (in milliseconds) to simulate slippage or latency
f. Modelling: Choose the testing model
| Model Name | Accuracy | Speed | Use Case | Features |
|---|---|---|---|---|
| Every tick based on real ticks | ★★★★★ (Highest) | ★☆☆☆☆ (Slow) | Closest to live trading | Reproduces actual tick data, including slippage and latency |
| Every tick | ★★★★☆ | ★★☆☆☆ | High-precision testing | Generates ticks algorithmically; faster but slightly simplified |
| 1 minute OHLC | ★★☆☆☆ | ★★★★☆ | Fast testing & parameter tuning | Uses only OHLC data per bar; suitable for simple entry logic |
| Open prices only | ★☆☆☆☆ (Basic) | ★★★★★ (Fast) | Initial screening | Evaluates only the opening price of each bar; fastest but least precise |
g. Deposit: Enter the margin amount and specify the currency unit
h. leverage: Select the leverage ratio based on your account settings
i. Optimization: Choose whether to enable or Disable optimization (start with disabled)
j. visual mode with the display of charts, indicators, and trades: Choose “Disabled” for now (optimization will be explained in the next section)
4. Set Parameters

- Open the “Setting” tab
- Double-click the Value column of the item you want to change, and enter your desired number
- .To use a saved .set file, right-click anywhere in the table → select “Load” → choose the file
- Review the loaded values and adjust them if needed
5. Start Backtest
Click “Start” at the bottom right to begin the backtest
Review Backtest Results
- Backtest tab: View statistics such as total net profit, profit factor, win rate, and more
- Graph tab: Check the equity curve
- Journal tab: See order history and error messages
What Is Optimization?
Optimization is the process of adjusting EA parameters to find the best-performing combination. Based on backtest results, you can fine-tune settings to maximize profits and minimize risks.
Goals of Optimization
- Maximize Performance
- Find the optimal combination of parameters (e.g., TakeProfit and StopLoss) to improve profitability. Even small changes can significantly impact results.
- Adapt to Market Conditions
- Markets constantly change. By adjusting EA settings to match past volatility or trends, you can achieve more stable performance.
- This is especially important during high-volatility periods or strong trending markets.
Optimization Procedure
1. Configure Test Environment
- Select “Fast genetic based algorithm”
- Avoid using “Every tick based on real ticks” with “Slow complete algorithm” on standard PCs—it may take too long or freeze
2. Set Parameters
- Open the “Inputs” tab
- Check the box in the “Variable” column for each parameter you want to optimize
- Enter values for “Start”, “Step”, and “Stop”
- Example: For TakeProfit, set Start = 20, Step = 5, Stop = 40 → MT5 will test 20, 25, 30, 35, 40
- Start with a small number of combinations (e.g., 3×3 = 9 patterns), then gradually increase (e.g., 3×9 = 27 patterns)
- Adjust based on your PC specs and time efficiency

3. Start Optimization
Click “Start” at the bottom right to begin optimization
Review Optimization Results
- Results appear in the “Optimization Results” tab
- Each row shows a parameter combination with stats like profit, number of trades, and drawdown
- Click column headers to sort by your preferred metric
- Right-click a result and select “Run Single Test” with This Setting to perform a backtest using that specific combination
Recommended Optimization Workflow
While results vary by EA logic, for EAs distributed by MT4U, backtest results using Open prices only and Real ticks are often similar (Open prices tend to perform slightly better). To optimize efficiently:
- Run optimization using “Open prices only” with multiple parameter combinations
- Right-click the best result and check the parameter values used
- Re-optimize using those values with narrower ranges
- Start with ±5, then narrow to ±1
- Repeat steps 2–3 until optimization with “Open prices only” is complete
- Run a single backtest using “Every tick based on real ticks” to confirm results are consistent
- Optimize TakeProfit and StopLoss using “Every tick based on real ticks” within ±1 to ±5 range (e.g., ±1 for TP=10, ±5 for TP=100)
- Save the best-performing result as a .set file
Final Notes
This guide may be long, but every step is essential for successful EA operation. When you receive an EA and its set file, always perform backtesting and optimization to match your trading environment.
MT4U EAs avoid excessive curve fitting by default—no day or time restrictions are set (except MT5’s 0:00–1:00). However, you can adjust these to optimize for specific sessions like NewYork or London.
You’re free to change currency pairs and timeframes, and even optimize indicator parameters to improve performance. Rather than using distributed settings as-is, perform your own optimization and save the results as a .set file for more stable outcomes.



