if order fails then MtSendOrder returns error code not RET_OK! and You can analyze returned codes always
please see our samples. for instance:
please see our samples. for instance:
SendOrderInfo soi; ::ZeroMemory(&soi,sizeof(soi)); strcpy(soi.symbol,"USDCHF"); soi.cmd=OP_BUY; soi.volume=100; soi.price=ask; if((err=api.SendOrder(&soi))!=RET_OK) { printf("Error sending order: %s\n",api.GetErrorDescription(err)); return(-1); } printf("8. long position opened\n");
I asked a related question to support@metaquotes.ru. Below is a snippet from the email:
Hello, Andrew Schwartz,
**begin snippet**
> On the MT3 api, when I call SendOrder and the return value is 0 (success), does that guarantee that the order will go through?
No.
> Does SendOrder perform an asynchronous call or a synchronous call? I noticed that the trade list is not updated immediately - this is concerning to me.
Asynchronous.
Best regards, Mazhit Mugattarov,
MetaQuotes Software Corp.
**end snippet**
I'm confused. If I get a RET_OK (return value of 0) as a response to the SendOrder call, then that guarantees that the order will go through? You seem to indicate that it does provide a guarantee, but Mazhit Mugattarov indicates that it does not.
Thank you in advance.
Hello, Andrew Schwartz,
**begin snippet**
> On the MT3 api, when I call SendOrder and the return value is 0 (success), does that guarantee that the order will go through?
No.
> Does SendOrder perform an asynchronous call or a synchronous call? I noticed that the trade list is not updated immediately - this is concerning to me.
Asynchronous.
Best regards, Mazhit Mugattarov,
MetaQuotes Software Corp.
**end snippet**
I'm confused. If I get a RET_OK (return value of 0) as a response to the SendOrder call, then that guarantees that the order will go through? You seem to indicate that it does provide a guarantee, but Mazhit Mugattarov indicates that it does not.
Thank you in advance.
there is misunderstanding, sorry
then which is correct? Could I get a clarification? If Mazhit is correct, I would like to ask my question again:
"Presumably, if/when my order appears on the list from MtGetTradeRecords, I know that my order was successfuly. However, how do I know if the order failed? How long should I wait before giving up?"
"Presumably, if/when my order appears on the list from MtGetTradeRecords, I know that my order was successfuly. However, how do I know if the order failed? How long should I wait before giving up?"
please try send order with wrong prices. You will receive error code not RET_OK. just do it.
That makes sense, and I am aware of that. I am concerned that I call MtGetPrices to get the prices, then I call MtSendOrder to place the order with the correct price. However, what if the price changes between when I call MtGetPrices and when I call MtSendOrder? Is the broker required to place an order within a certain time period of a MtGetPrices call?
Yeah, it's in the MT3 API, not in MQL.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Basically, I don't see any notification in the API that lets the client know that an order has failed. In my program, if an order fails, I might want to replace the same order with a different price. However, I don't want to be in a situation where I replaced an order, thinking that the first order failed, but I was incorrect and both succeeded, leaving me in a position with twice the position I wanted.
Thanks in advance.