What's the timing of an OrderClose()'s result being returned?

 

Hi everyone.

I hope you are fine. I have a question: What's the exact timing of an OrderClose()'s result(true/false) being returned? 

In the following code, will the result of OrderClose() be immediately returned in row1, so we can use it in row2 within the same tick?

Or shall we wait for the order being sent to the real market, then the result of filled or not comes back probably after a few ticks?

...

void OnTick()
{
    bool Order_close_result = false;
    ...
    Order_close_result = OrderClose(..., OrderClosePrice(), ...); //row1, close at market price
    ...
    if(Order_close_result) {...} //row2, to check if it is closed
    ...
}


The same confusion comes with OrderModify() too, will the result be returned immediately or after being sent to the real market?


Thank you very much!!

 

yum1573:

Or shall we wait for the order being sent to the real market, then the result of filled or not comes back probably after a few ticks?

The same confusion comes with OrderModify() too, will the result be returned immediately or after being sent to the real market?

It returns the result true/false. Therefor it has to wait for the operation to complete. There are no asynchronous functions in MT4. Any ticks that arrive, while the operation is in progress are lost.

 
William Roeder:

It returns the result true/false. Therefor it has to wait for the operation to complete. There are no asynchronous functions in MT4. Any ticks that arrive, while the operation is in progress are lost.


Thank you for your answer!! It helps a lot