Stop / kill calculating a function.

To add comments, please log in or register
Thierry Ramaniraka
540
Thierry Ramaniraka  
Hello again,
I need to stop calculating a function because of CPU.

I created a BUTTON.
TRUE state => I call + dysplay my_function.
FALSE state => I hide the dysplayed grapical objects and indications. (but the function is still there and take CPU ressources).

How can I stop / kill the function's calculation ?

Regards.
Thierry Ramaniraka
540
Thierry Ramaniraka  
Really no way to kill a function ?
Marco vd Heijden
Moderator
12383
Marco vd Heijden  

Finish the calculation (cycle) and then decide whether to process the result further or not.

There are trillions of true/false a second, this is how a computer operates.

kypa
1077
kypa  
Where is that function, in OnCalculate or OnEvent?
Thierry Ramaniraka
540
Thierry Ramaniraka  
kypa:
Where is that function, in OnCalculate or OnEvent?

Hello,
In "OnCalculate".

Thierry Ramaniraka
540
Thierry Ramaniraka  
Here is the illustration of what i want to do :
void Function_Already_in_OnCalculate()
      {
       bool My_Button_State=ObjectGetInteger(0,"My_Button",OBJPROP_STATE);

       if(My_Button_State==true)
             {
                  My_Called_Function();
             }

       if(My_Button_State==false)
             {
                  // Kill My_Called_Function
             }
      }
How can i do that the simpler way please ?
Marco vd Heijden
Moderator
12383
Marco vd Heijden  

You mean slower ?

Then you can put it in a timer so you can define the interval in MilliSeconds.

Thierry Ramaniraka
540
Thierry Ramaniraka  
Marco vd Heijden:

You mean slower ?

Then you can put it in a timer so you can define the interval in MilliSeconds.

Hello,
I mean really kill it.
Like it's never existed, and no calculated anymore.

Marco vd Heijden
Moderator
12383
Marco vd Heijden  

It's the correct approach true or false.

But you can not go back in time to undo the calculation if it already started if that is what you mean.

Probably just need optimization to make it more efficient.

Maybe you can enlighten us as to why you want to 'kill' the function ?

Thierry Ramaniraka
540
Thierry Ramaniraka  
I dysplay highs and lows of many timeframes with parameters "Processed_Periods".
But even if delete all objects, the calculation is still runing.

Maybe the best way,is to change "Processed_Periods = 0;" when button is FALSE. (?)
Thierry Ramaniraka
540
Thierry Ramaniraka  
Like this :
if(TLR_Button_Periods_Ranges_State==false)
             {
                  Periods_Ranges_To_Process=0;
                  ObjectDeleteAll();
             }
...
It calls a array. How can I nullify an Array ?
double m_MN1[][6];
ArrayCopyRates(m_MN1,Symbol(),PERIOD_MN1);
12
To add comments, please log in or register