Need help with sleep function

troniva
69
troniva  

Hello,

Can someone please repair my code?

I really don´t know why my Sleep function doesn´t work.

I am a beginner in programming so sorry for this stupid problem.. i really don´t know what is wrong.

Here is my code:

if ((ma27<ma467))
{

if(OrdersTotal()==0)
{
int openbuyTrend=OrderSend(Symbol(),OP_BUY,0.01,Ask,Slippage,Ask-99999*Point,Ask+800*Point);//Opening Buy
if(openbuyTrend==TRUE)
{Alert("Order opened !!!"); PlaySound("alert.wav");}

}
return Sleep(18000000); //// <----- WHY DOESN´T WORK ????

}

I just want to sleep all trading after close the trade on 5 hours so if you have some solution please give me the code.

Send please repaired code to my email tomas.fedarko@gmail.com

Thank you very very much!

Tomas

[Deleted]  

Why have you got "return" before your Sleep() function call?

CB

troniva
69
troniva  
cloudbreaker:

Why have you got "return" before your Sleep() function call?

CB


Well, it doesn´t work without that return too.
troniva
69
troniva  

I think i have found good buy signals but it always opens the next trade to early.

I just would like to see functional code that uses the sleep function because i just can´t use it :-(

[Deleted]  

Put a Print() statement before, and another one after the Sleep() statement (obviously with a smaller number of milliseconds) - that way you'll be able to see and time what is happening.

The "return" statement should not be there. What was your rationale?

CB

troniva
69
troniva  

Well, maybe it can be solved better with Orderselect() and Orderclosetime(), but i don´t know how to use it too.

I just want have no trades after close one for time 5 hours.

Do you know how to do it?



[Deleted]  

Yes I do know thanks.

However, since you know how your problem can be "solved better", go right ahead.

CB

William Roeder
23488
William Roeder  
Sleep doesn't work in the tester.