optimization 7 times slower than backtest

 

I have a problem with optimization: when I run a backtest with a strategy, it takes about 8 minutes. However, when I run a simple parameter optimization over the same strategy and period with 10 variants, the optimization takes around 58 minutes, which is more than 7 times longer. I didn’t have this issue until a few weeks ago. My CPU is a 16-core Ryzen, so that shouldn't be a problem. I also ran code from two months ago, and I got the same result. Is this an issue with MetaTrader, or what can I try to understand the problem better?

 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
Filip:

I have a problem with optimization: when I run a backtest with a strategy, it takes about 8 minutes. However, when I run a simple parameter optimization over the same strategy and period with 10 variants, the optimization takes around 58 minutes, which is more than 7 times longer. I didn’t have this issue until a few weeks ago. My CPU is a 16-core Ryzen, so that shouldn't be a problem. I also ran code from two months ago, and I got the same result. Is this an issue with MetaTrader, or what can I try to understand the problem better?

A single backtest has exclusive use of system resources whilst each core in an optimisation has to share. The impact on the speed of each iteration can be significant. 

 
Filip:

I have a problem with optimization: when I run a backtest with a strategy, it takes about 8 minutes. However, when I run a simple parameter optimization over the same strategy and period with 10 variants, the optimization takes around 58 minutes, which is more than 7 times longer. I didn’t have this issue until a few weeks ago. My CPU is a 16-core Ryzen, so that shouldn't be a problem. I also ran code from two months ago, and I got the same result. Is this an issue with MetaTrader, or what can I try to understand the problem better?

0) Make sure, you're running the test and optimization in similar tester modes!

1) Look into the logs. Maybe, just by accident, you're optimizing debug compiled variant of ex5-file whereas the single test was running in release variant. Also using the logs you can compare timing of the single test and optimization passes, then figure out why the difference.

2) Try to repeat the single test and optimization under more stable MT5 build, such as 4410 - the minimal supported from now on.