Optimizer getting slower and slower

 

Hi, I observe the optimizer in MT5 getting slower and slower over time. At first, it shows to need 20 hours for 10000 runs. After 2000 runs it shows 600hrs .


Quite often, when all agents are done, the optimizer waits and waits before it starts the next iteration.



Is there anything I can check in order to make it work faster?

 
😥
 
Eugen Funk:

Hi, I observe the optimizer in MT5 getting slower and slower over time. At first, it shows to need 20 hours for 10000 runs. After 2000 runs it shows 600hrs .

Quite often, when all agents are done, the optimizer waits and waits before it starts the next iteration.

Is there anything I can check in order to make it work faster?

for sure you can make your code to work faster, but issue is there and time increases in a polynomial manner. 

I asked for but nothing to do more.

https://www.mql5.com/en/forum/459941

Optimization of Optimization and Backtest
Optimization of Optimization and Backtest
  • 2024.01.04
  • www.mql5.com
As I see(please correct me if I am wrong), when a back test starts speed is very high and passing time and increasing positions/orders and all oper...
 
Mahdi Ebrahimzadeh #:

for sure you can make your code to work faster, but issue is there and time increases in a polynomial manner. 

I asked for but nothing to do more.

https://www.mql5.com/en/forum/459941

For me, when running optimization, the estimated time is quite accurate. Have you tried freeing resources as well as dynamically allocated memory in OnDeinit()?

 
Le Minh Duc #:

For me, when running optimization, the estimated time is quite accurate. Have you tried freeing resources as well as dynamically allocated memory in OnDeinit()?

actually no,

resources means indicators, arrays, structs, ..?

 
Le Minh Duc #:

For me, when running optimization, the estimated time is quite accurate. Have you tried freeing resources as well as dynamically allocated memory in OnDeinit()?

Thank you. Yes, but I am not sure if I free ALL ressources.

I currently assume, that if there is not log message about a memory leak, then all ressources are cleared?


Is there a way to verify that?

 
Eugen Funk #:

I currently assume, that if there is not log message about a memory leak, then all ressources are cleared?

Honestly, I do not know if we need to release memories end of each opt steps or they will automatically!?

based on what Le Minh said, if we release dynamic resources in OnDeinit function, there will not be any accumulation of source! Or at least I understand this from his response. I am waiting for his re-response to my next question.

Forum on trading, automated trading systems and testing trading strategies

Optimizer getting slower and slower

Le Minh Duc, 2024.01.28 04:13

For me, when running optimization, the estimated time is quite accurate. Have you tried freeing resources as well as dynamically allocated memory in OnDeinit()?


 
Mahdi Ebrahimzadeh #:

Honestly, I do not know if we need to release memories end of each opt steps or they will automatically!?

based on what Le Minh said, if we release dynamic resources in OnDeinit function, there will not be any accumulation of source! Or at least I understand this from his response. I am waiting for his re-response to my next question.


Yes I tried :)

 
Mahdi Ebrahimzadeh #:

actually no,

resources means indicators, arrays, structs, ..?

For resources that you use the ...Create() method, you should release them. For example, IndicatorCreate(), ResourceCreate()... When you don't use them anymore, use functions like IndicatorRelease(), ResourceFree(). Or dynamically allocated Arrays using the ArrayResize() method, when you don't use it . Instances are initialized with the keyword "new" and pointers can be released with "delete".

You can refer more here: https://www.mql5.com/en/docs/basis/variables/object_live

Documentation on MQL5: Common Functions / ResourceFree
Documentation on MQL5: Common Functions / ResourceFree
  • www.mql5.com
ResourceFree - Common Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Thank you!

Is there a way to see (profiler?) if all memoery if free after calling onDeinit? 🤔 This would give me confidence instead of searching all the code and guessing where I might have forgotten something.

 

The issue where multiple agents finish optimizing, but some remain in the process percentage, causing a wait for those slower agents, is something I found to be due to the EA using some parameter set during optimization that causes it to take a long time to process. For example, placing a large number of orders, being unable to place orders and waiting idly until the test optimization period is over, etc.

Personally, I initially addressed this by using various methods to terminate, such as:

OnTester - Every 1 minute:

  • If the current balance is < 40% of the initial balance (oninit), terminate. {Excessive drawdown}
  • If the open orders > 50 and the oldest order has been open for more than 1 week and still hasn't closed, terminate. {Too many open orders held for too long}
  • If open orders > 200, terminate. {Too many open orders}

Every 2 months:

  • If the balance < initial balance (oninit), terminate. {Growth is too slow}
  • If there are no positions in order close, terminate. {Too few orders}
  • If the number of closed orders in this period < 2 orders, terminate. {Too few orders}

Or any conditions you think might apply to your EA and cause it to be slow.


if that specific agent does not meet any of the specified cases but takes too long to process, use the function GetTickCount64() to count from when the EA was placed in milliseconds, and if it takes too long, terminate.

like ... 

int Tester_elapetimetickmilli = 2;
ulong millitick_startTime;
ulong millitick_elapsedTime;

millitick_elapsedTime = GetTickCount64() - millitick_startTime;
if (millitick_elapsedTime >= (Tester_elapetimetickmilli) * 60 * 1000)
{
   // terminate ...
}

// If processing takes longer than 2 minutes, terminate