"10008 - TRADE_RETCODE_PLACED" vs "10009 - TRADE_RETCODE_DONE"

 

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
 

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. 

 

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!

 
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)

 
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.

 

Forum on trading, automated trading systems and testing trading strategies

Looking for more clarity on 10008 vs 10009 return code

Jeepack, 2023.12.15 18:22

Hi, in this thread: "10008 - TRADE_RETCODE_PLACED" vs "10009 - TRADE_RETCODE_DONE"

...I'm not sure what the correct conclusion should be, the reason I ask is that all of a sudden, I have been receiving 10008 in situations where I used to receive 10009 (same broker, same EA, same type of trade, but different retcode).

OrderSendAsync used in both examples, OnTradeTransaction used to get result, just now as I was testing and it generated 10009 on one trade and then 10008 on the next trade 30 seconds later.

So now I'm thinking I should just check for both codes to know if the order is placed successfully and not bother with which of the two codes is returned.

Does this make sense? Seems random so I'm not 100% this is correct.

@Jeepack, in the future, please don't create new forum topics unnecessarily. Even if it is an old thread, if the subject matter is directly related, then please continue on an existing thread, instead of creating a new one.

 
@Jeepack #: ...I'm not sure what the correct conclusion should be, the reason I ask is that all of a sudden, I have been receiving 10008 in situations where I used to receive 10009 (same broker, same EA, same type of trade, but different retcode).

I believe the difference is related to the asynchronous order placement of the OrderSendAsync, versus the synchronous placement by OrderSend.

In the OrderSendAsync documentation, it is stated ...

Return Value

Returns true if the request is sent to a trade server. In case the request is not sent, it returns false. In case the request is sent, in the result variable the response code contains TRADE_RETCODE_PLACED value (code 10008) – "order placed". Successful execution means only the fact of sending, but does not give any guarantee that the request has reached the trade server and has been accepted for processing. When processing the received request, a trade server sends a reply to a client terminal notifying of change in the current state of positions, orders and deals, which leads to the generation of the Trade event.

The other two codes will probably occur after the placement status and be reported later in the transaction events.

10009

TRADE_RETCODE_DONE

Request completed

10010

TRADE_RETCODE_DONE_PARTIAL

Only part of the request was completed

EDIT: I suspect however, that in the case the broker processing is carried out fast enough to be reported by the end of the OrderSendAsync function, it may report 10009/10010 instead of 10008. This however, is just speculation on my part.
Documentation on MQL5: Trade Functions / OrderSendAsync
Documentation on MQL5: Trade Functions / OrderSendAsync
  • www.mql5.com
OrderSendAsync - Trade Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

I know the Problem, i had this years ago and i didnt found a Solution. Im sure it have have nothing to do with async.

i Guss ist a bug in mt

 
@amando #: I komme the Problem, i had this years Abo and i didnt found a Solution. Im stremmt have nothing to do with async. i Guss ist a bug in mt
Your English is a little "wonky" there. Can you perhaps please fix your post by using the automated translation instead?
 

Sorry, ist Not the englisch, ist the f.. iPad Spelling correction

 
Fernando Carreiro #:

@Jeepack, in the future, please don't create new forum topics unnecessarily. Even if it is an old thread, if the subject matter is directly related, then please continue on an existing thread, instead of creating a new one.

Sorry about that, thanks for moving the post.

Fernando Carreiro #:

EDIT: I suspect however, that in the case the broker processing is carried out fast enough to be reported by the end of the OrderSendAsync function, it may report 10009/10010 instead of 10008. This however, is just speculation on my part.

That was my guess too. Something about one replacing the other if the broker is quick enough maybe. There's something that goes on server side when you use OrderSendAsync that seems to sometimes randomly affect what you get with OnTradeTransaction. It's like, if you remember, when I was reporting that I was receiving some duplicate events in OnTradeTransaction on about 20% of my orders if I was sending more than one order at a time with OrderSendAsync. There was no clear pattern, sometimes it happened and other times it didn't. I still don't know for sure but your input helps a lot. Thanks 

amando #:

I know the Problem, i had this years ago and i didnt found a Solution. Im sure it have have nothing to do with async.

i Guss ist a bug in mt

Thanks for the reply, if I'm not the only one with the issue I guess that's probably a good sign!
"10008 - TRADE_RETCODE_PLACED" vs "10009 - TRADE_RETCODE_DONE"
"10008 - TRADE_RETCODE_PLACED" vs "10009 - TRADE_RETCODE_DONE"
  • 2013.01.15
  • www.mql5.com
What is the practical difference between "10008 - TRADE_RETCODE_PLACED" and "10009 - TRADE_RETCODE_DONE"? https://www.mql5...
Reason: