OrderSendAsynch has any disadvantage compared to OrderSend?
Why it is not used by default?
The advantage is that you code is not halted for the response from the trade server. Contrary to common believe, it is not faster. The time you will get to know the ticket is exactly the same as with Ordersend. So it is beneficial only if there is a reason to *not* wait for response. Sending a batch of orders for example.
OrderSendAsynch has any disadvantage compared to OrderSend?
Why it is not used by default?
Have you ever been dealing with async processing? The async method forces you to completely separate the processes of sending orders and managing the positions. In case of doubts you have no clue after you sent the order if it was executed or not, you have to catch it at another location in your code and translate/combine the incoming messages to what happened whenever before in your code. After sending an async order, all testing (opened positions, floating volume, pending orders etc.) you do immediately afterwards provide wrong results, in case of doubts.
The async method forces you to completely separate the processes of sending orders and managing the positions.
I use the async mode.
The EA waits (and freezes) until the server has responded upon your order. That makes the control part easier as you can put that in an if-clause.
The async order you fire and forget and e.g. after the next tick you have to check how your order was executed - it means you have to write an extra part in your code for this.
I use the async mode.
In Asynch mode, how I can get the ticket number of the order?
In normal mode terminal waits and after execution it makes the order ticket available in MqlTradeResult, so it can be processed immediately.
But in Asynch mode, as you said, I have to go back and search where is it and get its ticket.
In my case I need to capture each ticket after position opening and store it into array along with trailing distance, which is specific for each order.
Is there any way to do it in Asynch mode?
In Asynch mode response from trade server will not arrive to MqlTradeRequest for further processing?
The freeze is probably not caused by synced processing.
In Asynch mode, how I can get the ticket number of the order?
In the end it does not matter, cause transaction results can be delayed anytime, no matter if you use sync or async processing. The way you choose, storing tickets etc. will not work proper, when you don´t synchronize your signal flow with OnTradeTransaction(). It´s not that easy, but with enough effort it can be solved properly.
Have a look at:
https://www.mql5.com/en/forum/357245
![OnTrade/OnTradeTransaction - Are deal results always async? OnTrade/OnTradeTransaction - Are deal results always async?](https://c.mql5.com/36/47/ontrade-ontradetransaction-are.jpg)
- 2020.12.05
- www.mql5.com
In Asynch mode, how I can get the ticket number of the order?
In normal mode terminal waits and after execution it makes the order ticket available in MqlTradeResult, so it can be processed immediately.
But in Asynch mode, as you said, I have to go back and search where is it and get its ticket.
In my case I need to capture each ticket after position opening and store it into array along with trailing distance, which is specific for each order.
Is there any way to do it in Asynch mode?
I do it with this structure:
... bool oOk=true; ... //--- action and return the result if ( !OrderSendAsync(m_request,m_result) ) { // order arrived? Print(__FUNCTION__,"(",__LINE__,") FAILED: ",sym," T #",t," mag: ",OrderGetInteger(ORDER_MAGIC)," (",EnumToString(oTyp), ") cmt: ",m_result.comment,", retcode = ",sErr(m_result.retcode)," e: ",sErr()); // error oOk = false; } else { this.PrintResult(); } if ( !oOk ) { // set some variables to repeat the order after some time waiting and not later than ... if ( sig == ORDER_TYPE_SELL ) { LimitReTriesOrdSE++; TimeRetriesPosSE = TimeCurrent()+LimitReTriesOrdSE*60; } if ( sig == ORDER_TYPE_BUY ) { LimitReTriesOrdBU++; TimeRetriesPosBU = TimeCurrent()+LimitReTriesOrdBU*60; } } else { // all is ok // disable class variables if ( sig == ORDER_TYPE_SELL ) { LimitReTriesOrdSE = 0; TimeRetriesOrdSE = MaxDate; } if ( sig == ORDER_TYPE_BUY ) { LimitReTriesOrdBU = 0; TimeRetriesOrdBU = MaxDate; } sig = WRONG_VALUE; } // return the need of repetition, WRONG_VALUE=no repetition return(sig); }
OrderSendAsynch has any disadvantage compared to OrderSend?
Why it is not used by default?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
OrderSendAsynch has any disadvantage compared to OrderSend?
Why it is not used by default?