Handling of failed orders

 

Hi,

how are you handling the orders, if the OrderSend- or the OrderClose-Function returns -1?

I want my ea to open and close the order at a specific minute, and often the broker doesn't execute the orders in this minute.


Now I want my EA to try the OrderSend- or OrderClose-Function 4 times after the first try is failed.

Does anybody knows a better way for that, than putting my OrderSend- or the OrderClose-Function 4 times after below the first try?

 
It's very odd that a broker doesn't execute orders in certain minutes. You should check the error codes before blaming the broker using GetLastError().
 
sunshineh:

Does anybody knows a better way for that, than putting my OrderSend- or the OrderClose-Function 4 times after below the first try?

What is the error ? there are specific actions you need to do depending on what the error is . . . Errors

For example, error 128 - "Timeout for the trade has been reached. Before retry (at least, in 1-minute time), it is necessary to make sure that trading operation has not really succeeded (a new position has not been opened, or the existing order has not been modified or deleted, or the existing position has not been closed)"

 

Hi,

thank you for your answers!

I have checked the errors and got ERR_COMMON_ERROR (Number 2) and ERR_NO_CONNECTION (Number 6).

Have anybody already a code to solve this problem?

 
If you have no connection to your broker (Error 6) there is not much you can do about that . . . Error 2 you will need to investigate further and find the cause of it.
Reason: