System hang when removing indicators from charts

 

Hi everyone
I have written an expert that runs custom macdonrsi indicator on 3500 Renko charts with different size candles. In the end, when I want to delete the expert or change the profile, it automatically tries to close all these indicator handles at once, and that's why it hangs and I have to close Metatrader and open it again.
I tried to manually release the handles one by one inside the OnDeinit function.
My code:

void OnDeinit(const int reason)
  {

   for(int i=0;i<ArraySize(macdHandle.integer);i++)
      IndicatorRelease(macdHandle.integer[i]);
   for(int i=0;i<ArraySize(macdHandle2.integer);i++)
      IndicatorRelease(macdHandle2.integer[i]);

   EventKillTimer();

  }

Later, I tried to slow down the process by using the sleep function, but it didn't help :

void OnDeinit(const int reason)
  {

   for(int i=0;i<ArraySize(macdHandle.integer);i++)
     {IndicatorRelease(macdHandle.integer[i]);Sleep(20);}
   for(int i=0;i<ArraySize(macdHandle2.integer);i++)
     {IndicatorRelease(macdHandle2.integer[i]);Sleep(20);}

   EventKillTimer();

  }

Can you help me to solve this problem?
 
mammad0990:

Hi everyone
I have written an expert that runs custom macdonrsi indicator on 3500 Renko charts with different size candles. In the end, when I want to delete the expert or change the profile, it automatically tries to close all these indicator handles at once, and that's why it hangs and I have to close Metatrader and open it again.
I tried to manually release the handles one by one inside the OnDeinit function.
My code:

Later, I tried to slow down the process by using the sleep function, but it didn't help :

Can you help me to solve this problem?
Can anyone help me?
 
mammad0990 #:
Can anyone help me?

OnDeinit  only has a limited amount of time to process, after which it will be forcefully terminated. given that you say you are dealing with 3500 indicators it is likely that it is running out of time.

Slowing it down will only make it worse not better.

If it is causing your terminal to hang then maybe you need to scale back, and no you cannot extend the time.

 
Paul Anscombe #:

OnDeinit  only has a limited amount of time to process, after which it will be forcefully terminated. given that you say you are dealing with 3500 indicators it is likely that it is running out of time.

Slowing it down will only make it worse not better.

If it is causing your terminal to hang then maybe you need to scale back, and no you cannot extend the time.

Thank you for your answer. Can you guide me what exactly should I do?
 

you could use OnChartEvent to release all the handles when a specific key is pressed or key combination

assigning a custom hotkey to perform an action is a simple task:
https://www.mql5.com/en/code/50353

Screenshots with keyboard key press
Screenshots with keyboard key press
  • www.mql5.com
Capture widescreen screenshots by pressing the 's' hotkey on the keyboard