MT5 and speed in action - page 31

 
fxsaber:

If you run this EA on an account with no current positions or orders.

and then manually close the position opened by the EA, then there will be three open positions on the hedge (on the netting triple volume position).


Is this the correct behaviour? I probably do not understand the Terminal correctly. Then please clarify.

First of all you should read the help.

https://www.mql5.com/ru/docs/event_handlers/ontrade

Please note:

Обработчик OnTrade() вызывается после соответствующих вызовов OnTradeTransaction(). В общем случае нет точного соотношения по количеству вызовов OnTrade() и OnTradeTransaction(). Один вызов OnTrade() соответствует одному или нескольким вызовам OnTradeTransaction.

Simply put, the OnTrade() handler can be called for each individual trade. The consequence of closing a position can be the arrival of several separate transactions.

This is easily checked - just add Print() to OnTrade() of your example.

Plus I want to draw your attention to your previous test that you in vain expect to know the order ticket through OrderSendAsync().

Документация по MQL5: Обработка событий / OnTrade
Документация по MQL5: Обработка событий / OnTrade
  • www.mql5.com
//|                                               OnTrade_Sample.mq5 | //|                        Copyright 2018, MetaQuotes Software Corp. | //|                                             https://www.mql5.com | //| Expert initialization function                                   |...
 
Anton:

Plus I want to draw your attention, according to your previous test, that you expect in vain to find out the order ticket via OrderSendAsync().

It seems that it's not there anywhere. Only HistorySelect lags in OnTrade.

 
fxsaber:

It doesn't seem to be there anywhere. Only the HistorySelect lags in OnTrade are shown.

if (PositionSelectByTicket(Result.order)) // Если позиция открыта - закрываем.
 
Anton:

The first thing to do is to read the fact sheet.

https://www.mql5.com/ru/docs/event_handlers/ontrade

Please note:

Обработчик OnTrade() вызывается после соответствующих вызовов OnTradeTransaction(). В общем случае нет точного соотношения по количеству вызовов OnTrade() и OnTradeTransaction(). Один вызов OnTrade() соответствует одному или нескольким вызовам OnTradeTransaction.

Simply put, the OnTrade() handler can be called for each individual trade transaction. The consequence of closing a position can be the arrival of several separate transactions.

It is easily checked - just add Print() to OnTrade() of your example.

Of course, I have made the print. The question was not about the number of OnTrade calls but about the number of open positions.

After the first OnTrade, a market order is placed. On the next OnTrade, this market order must not allow opening more orders by the condition. But in the next OnTrade, the sum of OrdersTotal() + PositionsTotal() is also zero. Is it correct?

 
Anton:

Thanks, I didn't see the copy-paste piece.

 
fxsaber:

It doesn't seem to be there anywhere. Only HistorySelect lags in OnTrade are shown.

Caching of order selections still improved today, will be beta in a few hours.

 
Renat Fatkhullin:

Caching of order selections still improved today, will be beta in a few hours.

Do you mean HistorySelect? Just the auto-link does not lead to OrderSelect.

 
Nelson Wanyama:

Any idea why mt5 does not feature the 'Commissions' tab? They only pop up after a trade is closed.

Any idea why mt5 does not feature 'Commissions' tab? They only pop up after a trade is closed.



 
fxsaber:

Did the printout, of course. The question was not the number of OnTrade calls, but the number of open positions.

After the first OnTrade, a market order is placed. On the next OnTrade, this market order must not allow opening more orders by the condition. But in the next OnTrade, the sum of OrdersTotal() + PositionsTotal() is also zero. Is it correct?

It's all in the help: https://www.mql5.com/ru/docs/trading/ordersendasync

Успешное выполнение означает только факт отсылки, но не даёт никакой гарантии, что запрос дошел до торгового сервера и был принят для обработки.  Торговый сервер при обработке полученного запроса отправляет клиентскому терминалу ответное сообщение об изменении текущего состояния позиций, ордеров и сделок, которое приводит к генерации события Trade.
So OrdersTotal() can undoubtedly be null. So can PositionsTotal(). It all depends on the transactions, their type and content.
Документация по MQL5: Торговые функции / OrderSendAsync
Документация по MQL5: Торговые функции / OrderSendAsync
  • www.mql5.com
"и режим вывода сообщений в журнал "Эксперты". По умолчанию выводятся все детали.\r\n" //| Expert initialization function                                   | //| Expert deinitialization function                                 | //| TradeTransaction function                                        |...
 
Anton:

Everything is in the help: https://www.mql5.com/ru/docs/trading/ordersendasync

Успешное выполнение означает только факт отсылки, но не даёт никакой гарантии, что запрос дошел до торгового сервера и был принят для обработки.
So OrdersTotal() can certainly be null. So can PositionsTotal().

https://www.mql5.com/ru/docs/constants/tradingconstants/orderproperties#enum_order_state

Each order has a status that describes its status. To get information, useOrderGetInteger() orHistoryOrderGetInteger() function with modifier ORDER_STATE. Valid values are stored in the ENUM_ORDER_STATE enumeration.

ENUM_ORDER_STATE

Identifier

Description

ORDER_STATE_STARTED

Order checked for correctness, but not yet accepted by the broker



Doesn't Started-state occur after a successful OrderSendAsync?