What should I do if function Sleep(30000) does not work?

 

Is there any other way to wait 30 seconds? Can I use any other code to wait 30 seconds after modification opened orders?

----------------------------------- START IDEA -----------------------------------

I would like to modify opened order when current price of selected opened order is:

1/. BUY order:

if BID >= OrderOpenPrice()+30*Point then StopLoss = BID - 7*Point, TakeProfit = BID+1000*Point

2/. SELL order:

if ASK <= OrderOpenPrice()-30*Point then StopLoss = ASK +7*Point, TakeProfit = ASK-1000*Point

The opened order should be chcecked and modified every 30 seconds...

------------------------------------- STOP IDEA -----------------------------------

If have you any idea how to write proper code of modification of opened orders for above conditions please answer. Thank you.

 

assuming that your code is in a way that for every tick that comes from server, the start() function is invoked. At the time you opened order, just put

wait_some_time = TimeCurrent();


int wait_some_time=0;

int start()

{

//do stuff here, like trailing stops or other things

....

...

if(TimeCurrent() - Wait_some_time<30)

return(0);


/// do stuff here

....

...

}


Depending on your code, perhaps you need to use slightly different approach. According to sleep functionality, a sleep of 30 seconds, means that your EA during this time is not receiving ticks from the server, which might not be desirable.

 
abstract_mind:



assuming that your code is in a way that for every tick that comes from server, the start() function is invoked. At the time you opened order, just put

wait_some_time = TimeCurrent();


int wait_some_time=0;

int start()

{

//do stuff here, like trailing stops or other things

....

...

if(TimeCurrent() - Wait_some_time<30)

return(0);


/// do stuff here

....

...

}


Depending on your code, perhaps you need to use slightly different approach. According to sleep functionality, a sleep of 30 seconds, means that your EA during this time is not receiving ticks from the server, which might not be desirable.



Thank you - I will check it soon. Regards PUNCHER

 

wait_some_time is in seconds or miliseconds?









abstract_mind wrote >>



assuming that your code is in a way that for every tick that comes from server, the start() function is invoked. At the time you opened order, just put

wait_some_time = TimeCurrent();


int wait_some_time=0;

int start()

{

//do stuff here, like trailing stops or other things

....

...

if(TimeCurrent() - Wait_some_time<30)

return(0);


/// do stuff here

....

...

}


Depending on your code, perhaps you need to use slightly different approach. According to sleep functionality, a sleep of 30 seconds, means that your EA during this time is not receiving ticks from the server, which might not be desirable.


 
Function TimeCurrent( ) changes every second. Therefore, the condition as it is now is specified for 30 seconds. If you need to wait less than one second, you can replace TimeCurrent( ) with GetTickCount( ), which change the waiting period for 30 miliseconds.
Reason: