Download MetaTrader 5

Will operation of OrderSend and OrderClose successfully done but return false due to bad network in MT4?

To add comments, please log in or register
Amy Liu
645
Amy Liu  
In MT4, OrderSend() and OrderClose() send instructions to server, the server do the trade instructions and return a response. But, if the server do the trade instructions successfully but the response come back to client lost due to bad network, OrderSend() and OrderClose() should return false. This means the operations successfully done but functions get a bad return code. What should an EA do when this happen to avoid such bad logic? Thanks!
Marco vd Heijden
Moderator
4951
Marco vd Heijden  

OrderSend() returns a ticket number if successful or -1 if it fails.

So if there is no connection OrderSend() will return -1 and you can get additional information by calling the GetLastError() function.

OrderClose() returns true or false and will also return false in case of no connection.

Some robots will keep trying to close the order or will give off Alert() or Playsound() depending on how it was coded.

To add comments, please log in or register