sleep() not working in this code!! - page 2

 
sorry that was a typo, its right in the EA... i mean , in ea its "timedelay==true"....
 
kmnatarajan:
sorry that was a typo, its right in the EA... i mean , in ea its "timedelay==true"....

timedelay is a bool,  a bool is true or false . . .   so you don't need to say . . .

if(true == true) 

 you can simply write . . .

if(true)

 and specifically in the case of your code . . .

if(timedelay)
 
RaptorUK:

So you want the Order placed at the open of the 01:35 bar ? 


After your sleep BarTime equals 0,  this is less than Time[0]  so BuyOrder1 is called . . .   try this . . .

 

 By the way . . .  timedelay=true  should give an error ? 

I did exactly the same way u told, but still the EA works the same way....am just too confused.
 
kmnatarajan:
I did exactly the same way u told, but still the EA works the same way....am just too confused.

Ah,  yes . . .  make BarTime a static . . .
 
RaptorUK:
Ah,  yes . . .  make BarTime a static . . .


no dude, i declared bartime a static variable....still the same....
 
kmnatarajan:

no dude, i declared bartime a static variable....still the same....
You probably need to do the same for timedelay
 

ok dudes, i tried this way, and it worked for me...

thanks for helping all the way.....


    if (TimeHour(TimeCurrent()) == 1 && TimeMinute(TimeCurrent()) == 28)
    {
       BarTime = Time[0];
       Sleep(300000);
       timedelay=true;
       
     }
 
    if (  (Time[0]-BarTime) > (Time[0]-Time[1])&&timedelay )
    {
      BuyOrder1();
      
     } 
Reason: