Metatrader’s Strategy Tester allows you to optimize your expert advisor to find the most profitable settings for the multitude of possible input variable combinations. You can optimize an expert advisor on a specific chart for a specific time period to find out which input values produced the highest returns and lowest drawdown.
However, it is important to remember that you should not over-optimize. You may get amazing results with a specific input combination, but because the values are so constrained, you probably won’t see results like that in the future. When optimizing an expert advisor, remember to use your head and think about why you are getting the results you are. Was it from one huge winner that you are unlikely to see in the future? Or did it win many times, making it a plausible trade setup for the future.
Don’t forget, you need to have high quality minute data for optimization to be worthwhile. See our article on setting up your metatrader history data.
To get started optimizing your expert advisor, open Strategy Tester. If you are new to backtesting, read our article: How to Backtest in Metatrader
Select the Expert Advisor from the pull down menu. Choose a currency Symbol and Period. Select Every Tick for Model. Check Use Date and select a time frame that you have high quality minute history data for. Finally check the box next to Optimization.
Next, click on the Expert Properties button on the right. Select the INPUTS tab to enter the range of values you will optimize for. The Start value is the lowest value that you start from. Stop is the highest. And Step is the increment that you step through the range.
For the TakeProfit value, you can see that we start at 50, step through at 25, and stop at 300. This will test every value inbetween 50 and 300 in a 25 increment. So, 50, 75, 100, 125, all the way up to 300. The same idea applies to the other variables.
The checkbox on the left must be checked to optimize for that variable. Otherwise, it will use the regular Value.
When you’re finished entering your input values, click OK. Now we’re ready to start the optimization. Click the Start button on the bottom right of the Strategy Tester window. The backtest may take minutes or hours depending on how many values you are optimizing for. You may want to choose a larger increment Step value or a smaller range if it is taking too long.
After the optimization has completed, select the Optimization Results tab to look through the results. You can sort by the values at the top. Select Profit to view in order of highest returns, or Drawdown to see which values had the least risk.