Question.. Sleep(3600000) After S/L or T/P

 
   int last_closed_order_ticket;
   int last_closed_time = 0;
   for(int k=9;k>=0;k--) {
      if(OrderSelect(k,SELECT_BY_POS,MODE_HISTORY)) {
         if(OrderCloseTime()>last_closed_time)
         {
         last_closed_time=OrderCloseTime();
         last_closed_order_ticket=OrderTicket();
         }
      if(last_closed_time < TimeCurrent()){
        Sleep(3600000)
        }
      }
   }

I want my ea sleep 1 hour after T/P or S/L.

But.. it doesnt work. i tried to do my best for finding, editing, and coding for correct code, but I counldnt.

Please kindly leave your precious advise.

 

Sleep does not work in strategy tester...


//z

 

Then, what else can i do??

 
   int last_closed_order_ticket;
   int last_closed_time = 0;
   for(int k=9;k>=0;k--) {
      if(OrderSelect(k,SELECT_BY_POS,MODE_HISTORY)) {
         if(OrderCloseTime()>last_closed_time)
         {
         last_closed_time=OrderCloseTime();
         last_closed_order_ticket=OrderTicket();
         }
      }
   }
      if(last_closed_time < TimeCurrent()){
        Sleep(3600000)
        }

regardless last_closed_time is always smaller from TimeCurrent()

u need something like this

while(TimeCurrent() < last_closed_time + 60*60){
    return(0);
    }

& like zzuegg said Sleep does not work in strategy tester...

 
qjol:

regardless last_closed_time is always smaller from TimeCurrent()

u need something like this

& like zzuegg said Sleep does not work in strategy tester...

use if and not while. Although while will also work it looks very strange and confusing, especially to newbies who might not yet have fully understood the full meaning and differences of if and while and their usual usage pattern.


You are simulating an if with a while and it only works because there is a return() inside it that will always break out of the while loop in the very first iteration (breaking the loop). This is not very newbie friendly. You should use if if you mean if and not abuse a broken loop construct when there is nothing to loop in the first place.

if (TimeCurrent() < last_closed_time + 60*60) {
   return(0);
}