Sleep Alternative!!

Back to topics list To post a new topic, please log in or register
avatar
26
ceaser234 2016.06.02 08:49
 

Hey !

I know that sleep command does not work in strategy tester.So i searched and try some ideas described by users,but none work for me.I want to make EA sleep if condition is true but when i try its alternatives at someconditions it does not sleep and some time it does not processed further. I cannot under stand what actually the problem is .Hope so that someone can help me to know the problem.

Here is one of  alternatives i try

 int _time_waiting=0;
 int _PauseTime=TimeCurrent();

Void OnTick()
{ 
  if( //condition true )          // if first condition true move further                                      
 _time_waiting = _PauseTime + 10;  // wait for 10 sec
  // Do stuff                      // 
  if ( TimeCurrent() >= _time_waiting )    // wait until 10 seconds have passed
   {
    // Do Stuff                         // the block to be processed after sleep command 
   }

}  




avatar
2017
gooly 2016.06.02 12:44 #
 

I always use this kind of wait/sleep:

void OnTick() {
   datetime waitsec = 100;
   static datetime nextAction=0;
   if (TimeCurrent()<nextAction) return;
   ...
   nextAction = TimeCurrent()+waitsec;
   ...
}


avatar
12985
WHRoeder 2016.06.02 14:10 #
 
ceaser234: I cannot under stand what actually the problem is .
Until you return to the tester, to get the next tick, nothing changes.
Back to topics list  

To add comments, please log in or register