Discussion of article "Trade Events in MetaTrader 5"

 

New article Trade Events in MetaTrader 5 is published:

A monitoring of the current state of a trade account implies controlling open positions and orders. Before a trade signal becomes a deal, it should be sent from the client terminal as a request to the trade server, where it will be placed in the order queue awaiting to be processed. Accepting of a request by the trade server, deleting it as it expires or conducting a deal on its basis - all those actions are followed by trade events; and the trade server informs the terminal about them.

Generation of Trade Events

Author: MetaQuotes

 

I would like to clarify a few points.

1. the article implies that the OrderCheck() function is intended for the primary check of a request, and the primary check with the help of the OrderCheck() function is performed directly by the server (on the server side), not in the terminal. Is this correct?

Документация по MQL5: Торговые функции / OrderCheck
Документация по MQL5: Торговые функции / OrderCheck
  • www.mql5.com
Торговые функции / OrderCheck - Документация по MQL5
 

2. The reference book states that for the OrderSend() function "in case of a successful basic structure check, true is returned". From this we can conclude that true is returned immediately after checking the request for correctness.

But a little lower in the note it is added that "if the order is successfully accepted by the trade server, the OrderSend() function returns true". This note implies that true is returned only after the server accepts the order.

Meanwhile, there may be situations when the request has already been checked for correctness but has not been accepted by the broker yet. Therefore, please clarify at what point the OrderSend() function returns true - immediately after checking the request for correctness or only after the server accepts the order?

Документация по MQL5: Торговые функции / OrderSend
Документация по MQL5: Торговые функции / OrderSend
  • www.mql5.com
Торговые функции / OrderSend - Документация по MQL5
 
Yedelkin:

I would like to clarify a few points.

1. the article implies that the OrderCheck() function is intended for the primary check of a request, and the primary check with the help of the OrderCheck() function is performed directly by the server (on the server side), not in the terminal. Is it correct?

As far as I understand processing is performed on the client terminal side.

It is also confirmed by the following post.

 

3. The article states that "requests received by the trade server are stored in the form of orders, which can be pending or immediate execution at market prices".

As we know, Instant Execution is one of the three market order execution modes. So the question arises, what happens to market orders in Market Execution and Request Execution modes? Can we generalise that "requests received by the trade server are stored as orders, which can be pending or immediate market orders at market prices"?

 
Interesting:

As far as I understand processing is performed on the client terminal side.

This is also confirmed by the following post.

OK, I suggest we wait for an official response. Thanks, as always, for the additional information. That's what I thought earlier too.

Addendum. I even realised what might have confused me in this question. In the article the phrase "primary processing" is given a reference to the OrderCheck() function, and I took this reference at face value, without any hindsight.

 
Yedelkin:

I would like to clarify a few points.

1. the article implies that the OrderCheck() function is intended for the primary check of a request, and the primary check with the help of the OrderCheck() function is performed directly by the server (on the server side), not in the terminal. Is it correct?

The article says that the primary internal check is performed in the terminal. OrderCheck() also works in the terminal, nothing is sent to the server.
 
Rosh:
The article says that the initial check is performed in the terminal. OrderCheck() also works in the terminal, nothing is sent to the server.

The article says: "after sending a request, it arrives at the server and undergoes initial check".

I was also confused by the fact that in the article the phrase "primary processing" is given a reference to the OrderCheck() function, so I took this reference at face value, without a second thought.

 
Yedelkin:

2.

Meanwhile, there may be situations when the request has already been checked for correctness but has not been accepted by the broker yet. Therefore, please clarify at what exact moment the OrderSend() function returns true - immediately after checking the request for correctness or only after the server accepts the order?

Correct request is accepted by the server and the response is sent to the terminal in the retcode field of MqlTradeResult structure - https://www.mql5.com/en/docs/constants/errorswarnings/enum_trade_return_codes.

Code

Identifier

Description

10008

TRADE_RETCODE_PLACED

Order placed

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

Correct request is accepted by the server and the answer is sent to the terminal in the retcode field of the MqlTradeResult structure - https://www.mql5.com/en/docs/constants/errorswarnings/enum_trade_return_codes.

Code

Identifier

Description

10008

TRADE_RETCODE_PLACED

The order is placed

So you mean to say that the OrderSend() function returns true only after the server accepts (places) the order?
 
Yedelkin:


Also, I was confused by the fact that the article gives the phrase "initial processing" as a reference to the OrderCheck() function, and I took that reference at face value, without hindsight.

You confused me too. I removed the reference from the combination "primary check".