how can introduce a delay

 

hi guys.......i have a problem. i need to avoid to open an order after i have closed another order in the same bar so...i have thought to introduce a delay. i have tried with " sleep " but it doesn t go. i tried with " timecurrent()-orderopentime()> x "............but nothing. u have an idea??? i use 15 minutes as timeframe .
for example: order buy at 4.00 pm and close at 4.07 pm i want to wait until the next bar ( 4.15 pm) to introduce eventually another order.

how can i do????


thanksssssssssssssssssssss

 
Use a variable that changes when the next bar is opened, for example:
double check;
if (check!=Close[1]-High[2])
orderSend.....whatever

bool ans=orderclose....Whatever
if (ans==True)
check=Close[1]-High[2];

of course this way your ea keeps checking whether the variable "check" has changed but it stays the same until the next bar is opened. It is very unlikely that when the next bar is opened the value of "check" is still equal to the previous "Close[1]-High[2]". Think simple!
 

i will try...but i dont understand why the function "sleep" doesnt go!!! :-)))) i have never used the boolean variable. i try....then i will say u. anyway....as used.....thanks :-))

 

THANKSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS :-)))))))))))))

 
giulioron:

i will try...but i dont understand why the function "sleep" doesnt go!!! :-)))) i have never used the boolean variable. i try....then i will say u. anyway....as used.....thanks :-))

Sleep() does not work in Tester if that's what u are trying to do... Note also that the passed parameter is in milliseconds.

 
giulioron:

THANKSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS :-)))))))))))))

You are welcome! Glad to be of any help!

Reason: