return value of 'OrderSend' should be checked - page 2

 
angevoyageur:
Yes, and your answer is not enough either. So my post.
If you think so, thank you for sharing.
 
figurelli:
If you think so, thank you for sharing.
I do agree with Alain... What about if you get a TRADE_RETCODE_DONE_PARTIAL ? In this case you will receive a confirmation the order was correctly sent, but it was not correctly EXECUTED... In this sense you have to clearly specify what messages you are expecting, otherwise you have a different situation and must be treated as an exception.
 
Malacarne:
I do agree with Alain... What about if you get a TRADE_RETCODE_DONE_PARTIAL ? In this case you will receive a confirmation the order was correctly sent, but it was not correctly EXECUTED... In this sense you have to clearly specify what messages you are expecting, otherwise you have a different situation and must be treated as an exception.
Thank you Malacarne, you are right, but this is not my point, I'm not talking about OrderSend() merit, but about if/else in general. 
 

Here is my point:

Forum on trading, automated trading systems and testing trading strategies

Multiple Order Entry Problem for live account with a specific broker

figurelli, 2014.05.16 12:38

Hi FinanceEngineer, you are right, however the first thing to manage is select a low latency broker, since markets are each time faster, and it will be usual such problems.

Also, it's always good think about the worst case, because you can have a low latency broker but at some moments of day a big delay, for instance when you have relevant news.

Anyway, OrderSend() in MT5 is not so easy to manage as MT4, because MT4 returned value is a Ticket. This change was necessary at MT5 because asynchronous communication of stock markets, introduced at MQL5 architecture, that is enabled to communicate with broker OMS protocol (like FIX, for instance).

But I think this is the big change of OMS for order management today, since it's very hard get a real time Ticket, and MT5 is updated to this new scenario, mainly if we use stock markets, where we have more latency.

In this sense, the more relevant thing you do after a OrderSend() at MT5 is check PositionSelect(), and I strongly suggest use my proposed PositionSelectTimeout() workaround, for all reasons above.

The only way I see to think about worst cases is manage all the if { } else { } conditions after sending an order to the market, in a way you can manage any situation.

I would like to have catch { } too, but we can use GetLastError() to do something near this.

This because you also need the Ticket to confirm a position and MT5 OrderSend() don't return the ticket as sychronous as MT4 does.


 
angevoyageur:
Yes, and your answer is not enough either. So my post.

This ERROR statement is   "return value of 'OrderSelect' should be checked"


I do like below this. The result is ok, the error statement already gone.

I just do it like this: 


before:

OrderSelect(i,SELECT_BY_POS,MODE_TRADES);


after:

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)); else;

 
Mas-eToro:

This ERROR statement is   "return value of 'OrderSelect' should be checked"

after:

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)); else;

Hello Mas-eToro,

this whole post is about MQL5 functions and programming language...

The OrderSelect function you're referring to is used in MQL4. Please post MQL4-related questions on the MQL4 forum.

MQL4: automated trading forum
  • www.mql5.com
MQL4: automated trading forum
 
OrderSend
 
bain003:
What's the point of this screenshot ?
 
Why am I notified on topics I didn't put a star upon, nor opened ? 
 
Icham Aidibe:
Why am I notified on topics I didn't put a star upon, nor opened ? 
Because it's your topic. It's new feature :-) You can modify the settings in your profile under "Notifications".
Reason: