running EA or custom indicator every 10 sec

 

Hi there,

I need help on this. I want my custom indicator to be tick independent and run every 10 sec. I looked at the forums and tried :


int start()
{
while( !IsStopped() )

{
WindowRedraw();

Sleep(10000);

// my code

}
return(0);
}

And also tried:

int init()
{
while( !IsStopped() ) { start(); Sleep(10000); }

return(0);
}


but that code does not work, it loads my CPU and then I have to kill metatrader.

Any ideas?

 

int start()
{
while( !IsStopped() )

{
RefreshRates();

... your code

Sleep(10000);

}
return(0);
}
---------

The above should work, depending on what is in your code.

 
phy:

int start()
{
while( !IsStopped() )

{
RefreshRates();

... your code

Sleep(10000);

}
return(0);
}
---------

The above should work, depending on what is in your code.

I used your code -did not include mine- and still have high load in my CPU that requires killing MT4. Any other ideas?

Thanks for the help

 

Oh, can't be used for Indicator, as indicator ignores Sleep() command...

Works for EA or Script.

Endless loop in an indicator is not a good thing, as you have seen.

Reason: