Download MetaTrader 5

"10008 - TRADE_RETCODE_PLACED" vs "10009 - TRADE_RETCODE_DONE"

To add comments, please log in or register
hatlle
68
hatlle  

What is the practical difference between "10008 - TRADE_RETCODE_PLACED" and "10009 - TRADE_RETCODE_DONE"?

https://www.mql5.com/en/docs/constants/errorswarnings/enum_trade_return_codes


Documentation on MQL5: Standard Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
Documentation on MQL5: Standard Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
  • www.mql5.com
Standard Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes - Documentation on MQL5
Sergey Golubev
Moderator
94654
Sergey Golubev  

Quote from this page The Structure of a Trade Request Result (MqlTradeResult) :

As result of a trade request, a trade server returns data about the trade request processing result as a special predefined structure of MqlTradeResult type.

struct MqlTradeResult
  {
   uint     retcode;          // Operation return code
   ulong    deal;             // Deal ticket, if it is performed
   ulong    order;            // Order ticket, if it is placed
   double   volume;           // Deal volume, confirmed by broker
   double   price;            // Deal price, confirmed by broker
   double   bid;              // Current Bid price
   double   ask;              // Current Ask price
   string   comment;          // Broker comment to operation (by default it is filled by the operation description)
   uint     request_id;       // Request ID set by the terminal during the dispatch 
  };

So, as I understand, 10008 is a special/particular case of 10009. If I am wrong so sorry. 

hatlle
68
hatlle  

Thanks for your reply.

I was specifically interested in what they both mean in terms of actual success of trade requests.

In particular, does anyone know if is it possible for 10009 to occur without 10008 having first occurred? It seems that it must be, because if 10009 automatically occurred at the end of each trade request then it would overwrite any previous error when retrieving the retcode.

If 10009 can't occur without 10008 previously having occurred then it seems utterly superfluous in that context.

But if 10009 can occur on its own, then what exactly does it mean for the success or failure of the trade request? Simply stating that the request is "DONE" does not necessarily imply the request was either successful or unsuccessful - just that the request has finished.

10009 seems entirely nonsensical, but I don't want to ignore it from my retcode handling if it is important!


phi nuts
2184
phi nuts  
hatlle:

Thanks for your reply.

I was specifically interested in what they both mean in terms of actual success of trade requests.

In particular, does anyone know if is it possible for 10009 to occur without 10008 having first occurred? It seems that it must be, because if 10009 automatically occurred at the end of each trade request then it would overwrite any previous error when retrieving the retcode.

If 10009 can't occur without 10008 previously having occurred then it seems utterly superfluous in that context.

But if 10009 can occur on its own, then what exactly does it mean for the success or failure of the trade request? Simply stating that the request is "DONE" does not necessarily imply the request was either successful or unsuccessful - just that the request has finished.

10009 seems entirely nonsensical, but I don't want to ignore it from my retcode handling if it is important!


10008 is for OrderSendAsync.

This is language problem. For example, a boss tell his employee to do something and his employee reply "considered done", when the employee finish with what his boss was asked him to do, he tell his boss, "It's done, Sir"

In this case, "10009 - TRADE_RETCODE_DONE" means successful, that your request is completely done . There's also 10010 - TRADE_RECODE_DONE_PARTIAL, for example only half of the lot is opened, usually for IOC (Immediate Or Cancel) type of order (IOC- Investopedia)

hatlle
68
hatlle  
phi.nuts:

10008 is for OrderSendAsync.

This is language problem. For example, a boss tell his employee to do something and his employee reply "considered done", when the employee finish with what his boss was asked him to do, he tell his boss, "It's done, Sir"

In this case, "10009 - TRADE_RETCODE_DONE" means successful, that your request is completely done . There's also 10010 - TRADE_RECODE_DONE_PARTIAL, for example only half of the lot is opened, usually for IOC (Immediate Or Cancel) type of order (IOC- Investopedia)

OK, that clears it up for me, thank you.

I was confused because I was using the line:

   if(mresult.retcode==10009 || mresult.retcode==10008) //Request is completed or order placed

... which is found in the article Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners, where it mentions:

The return code 10009 shows that the OrderSend request was completed successfully, while 10008 shows that our order has been placed. That is why we have checked for any of these two return codes. If we have any of them, we are sure that our order has been completed or it has been placed.

It makes more sense then if 10008 is for OrderSendAsync and 10009 is just for OrderSend.

Thanks.



To add comments, please log in or register