OrderSend() questions - page 7

 

Are the fields to be filled in different than

SYMBOL_TRADE_EXECUTION_EXCHANGE

Exchange execution

differ from the fields at

SYMBOL_TRADE_EXECUTION_MARKET

Execution of orders on the market

???

help has an example for market only

Market Execution

A trade order to open a position in the Market Execution mode (Market Execution mode). Requires the specification of 5 fields:

  • action
  • symbol
  • volume
  • type
  • type_filling

You can also specify magic and comment fields.

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
 

I've read the documentation, searched the forum... Completely confused. Please, if you don't mind, explain to me in N+1 times.

1. i am sending a trade request usingOrderSend. This function returns true.

We analyzeretcode (MqlTradeResult). The variable has the valueTRADE_RETCODE_DONE.

Does this situation guarantee the actual order execution on the server? Or is there still a need to perform some checks in OnTrade, OnTradeTransaction? Then what is the point of analyzingretcode if it is of no use?

I.e. the need for OnTrade and OnTradeTransaction when usingOrderSendAsync() is clear to me.

Are they necessary when using theOrderSend() function? Does it unconditionally wait for the order execution/rejection on the server before sending the subsequent code to the Expert Advisor?

 
voix_kas:

...

Are they needed when usingOrderSend()? Does it unconditionally wait for the execution/rejection of the order on the server before sending the execution of the subsequent EA code?

If I'm not mistaken, OrderSend doesn't wait for the execution of the order, it only reports that the order was correct and was sent to the server.

The returned value is

If the basic check of structures (pointer check) is successful, it returns true - it doesn't indicate successful execution of the trade operation. To get a more detailed description of the result of the function execution, analyze the fields of the result structure.
 
voix_kas: I send a trade request usingOrderSend. This function returns true.

2. analyseretcode (MqlTradeResult). The variable has the valueTRADE_RETCODE_DONE.

Does this situation guarantee the actual execution of an order on the server?

retcode can return something other than RETCODE_DONE :). But if a trade server returns exactlyTRADE_RETCODE_DONE (order executed), then why else should I check? In my humble opinion, in this situation the OnTrade, OnTradeTransaction functions would simply duplicate the retcode.
 
fyords:

If I'm not mistaken, OrderSend doesn't wait for the order to be executed, but only reports that the order was true and sent to the queue server.

In that case, "true" alone would have been enough. But the developers have provided a retcode that is supposed to storethe "Trade serverreturn code".

I.e., after OrderSend() function works , I seeTRADE_RETCODE_DONE in the second line of codeand try to change, for example, a position just opened (which logically should exist) in the third code line. However, PositionSelect returns false. The iteration is repeated. As a result, a double position is opened by mistake.

How can we protect ourselves against this situation?

1. Be guided only by retcode and "forget" aboutOnTrade?

2. Guided only byOnTrade and forget about retcode?

 
Yedelkin:
retcode can return not only RETCODE_DONE :) But if a trade server returns exactlyTRADE_RETCODE_DONE (order executed), then why else should I check something else? In my humble opinion, in this situation the OnTrade, OnTradeTransaction functions would simply duplicate the retcode.

Judging by the list of"Trading server return codes", there is only one uncertainty possible in the market request execution mode:TRADE_RETCODE_LOCKED. And here, perhaps, we cannot do without OnTrade.

Let me ask what connection you personally use?

Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Коды возврата торгового сервера
Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Коды возврата торгового сервера
  • www.mql5.com
Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Коды возврата торгового сервера - Документация по MQL5
 
voix_kas: Judging by the list of"Trade server return codes", there is only one uncertainty possible in the market request execution mode:TRADE_RETCODE_LOCKED. And here, perhaps, we cannot do without OnTrade.

May I ask which bindings you personally use?

There is also "Placed". It is them (Placed/Done) that I check from the point of view of successful request sending.
 
Can you quote a specific code?
 
voix_kas: Can you quote a specific code?
No, I can't give you a specific code. Firstly, it's been sealed in classes since a year ago, and secondly, you have to look for it...You asked - What kind of a binder am I using? - I answered sincerely.
 
voix_kas:

How can you insure yourself against such a situation?

1. Only use retcode and "forget" aboutOnTrade?

2. Should I only useOnTrade and not use retcode?

It is most reliable to follow OnTrade, but you can also do without it - analyze the completed transaction (ResultDeal()).

There will be an article on this very subject soon.

Reason: