Download MetaTrader 5
To add comments, please log in or register
Have you just installed MetaTrader 5? Learn it in details!
ceaser234
56
ceaser234 2016.06.02 06: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 
   }

}  


Carl Schreiber
5934
Carl Schreiber 2016.06.02 10: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;
   ...
}
whroeder1
13596
whroeder1 2016.06.02 12:10  
ceaser234: I cannot under stand what actually the problem is .
Until you return to the tester, to get the next tick, nothing changes.
/
To add comments, please log in or register