Hello,
I tried to use the Sleep() function in my EA but it is not working as expected.
I even put it into the start() function at the beginning but I get log-entries for every single tick.
I do this to run every minute (it works) in my EA:
timeWaiting = TimeMinute(TimeLocal());
while (TimeMinute(TimeLocal()) == timeWaiting){
Sleep(100);
}
RefreshRates();
Test this:
timeWaiting = TimeSeconds(TimeLocal())+10;
while (TimeSeconds(TimeLocal()) <= timeWaiting){
Sleep(100);
}
RefreshRates();
But why is the Sleep() function not working in my case? What is the reason? Can't I test Sleep() in the StrategyTester?
My problem was the execution of sleepfunction was not accurate. I only use the sleepfunction, so that MT4 not freeze in a while-loop. Now the while-loop measures time.
I´m a newbie, but I guess that the sleep, function in "StrategyTester" is disabled. It would be logical to disable the sleep-function while backtesting...
I wish you the best and I hope a "Guru" will pick up this topic and give you the correct answer!
try
int start() { Alert (TimeToStr(TimeLocal(),TIME_SECONDS)); Sleep(10000); // sleep for 10seconds Alert (TimeToStr(TimeLocal(),TIME_SECONDS)); return(0); }
& c what happens
I´m a newbie, but I guess that the sleep, function in "StrategyTester" is disabled. It would be logical to disable the sleep-function while backtesting...
int start(){ static datetime delayTime; if (TimeCurrent() < delayTime) return; : if (condition){ delayTime = TimeCurrent()+ 60; return; // wait a minute }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I tried to use the Sleep() function in my EA but it is not working as expected.
I even put it into the start() function at the beginning but I get log-entries for every single tick.