"Floating PositionSelect() error - page 7

 
prostotrader:
It does not matter what order and what is the volume

The scheme is as follows:

  1. You set a pending order, set the volume of the order in the m_volume variable
  2. When TRADE_TRANSACTION_DEAL_ADD is received, compare the position volume with m_volume variable and check if the initial order still hangs there (maybe it was a partial execution and you have added the volume manually).

 
prostotrader:

Hi!

The situation is as follows MT5, build 1375

In its work, when trading futures, the robot uses the OrderSendAsync() function.

Suppose that there is an open position with a volume of 2 contracts.

How should I perform logging to inform the developers about the error?

There is an example of an oscillator that listens to TradeTransaction events in the article " Where to start when creating a trading robot for the Moscow Exchange MOEX ".

Try to run it and see the logs of executed trades. There should be no questions.

An example of how this "listener" works:

2016.06.09 14:51:19.763 TradeTransactionListener (Si-6.16,M15)  LAST PING=14 ms
Покупка
2016.06.09 14:51:24.856 TradeTransactionListener (Si-6.16,M15)  1. OnTradeTransaction
2016.06.09 14:51:24.856 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_ORDER_ADD order #49118594 ORDER_TYPE_BUY ORDER_STATE_STARTED   
2016.06.09 14:51:24.859 TradeTransactionListener (Si-6.16,M15)  2. OnTradeTransaction
2016.06.09 14:51:24.859 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_REQUEST
2016.06.09 14:51:24.859 TradeTransactionListener (Si-6.16,M15)  MqlTradeResult: order #49118594  retcode=TRADE_RETCODE_PLACED 
2016.06.09 14:51:24.859 TradeTransactionListener (Si-6.16,M15)  3. OnTradeTransaction
2016.06.09 14:51:24.859 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_ORDER_UPDATE order #49118594 ORDER_TYPE_BUY ORDER_STATE_REQUEST_ADD   
2016.06.09 14:51:24.881 TradeTransactionListener (Si-6.16,M15)  4. OnTradeTransaction
2016.06.09 14:51:24.881 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_ORDER_UPDATE order #49118594 ORDER_TYPE_BUY ORDER_STATE_PLACED   
2016.06.09 14:51:24.881 TradeTransactionListener (Si-6.16,M15)  5. OnTradeTransaction
2016.06.09 14:51:24.881 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_ORDER_DELETE order #49118594 ORDER_TYPE_BUY ORDER_STATE_PLACED   
2016.06.09 14:51:24.884 TradeTransactionListener (Si-6.16,M15)  6. OnTradeTransaction
2016.06.09 14:51:24.884 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_HISTORY_ADD order #49118594 ORDER_TYPE_BUY Si-6.16 ORDER_STATE_FILLED   (MOEX ticket=3377179723)
2016.06.09 14:51:24.884 TradeTransactionListener (Si-6.16,M15)  7. OnTradeTransaction
2016.06.09 14:51:24.885 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_DEAL_ADD deal #6945344 DEAL_TYPE_BUY Si-6.16 1.00 lot   (MOEX deal=185290434)
Установка SL/TP
2016.06.09 14:51:50.872 TradeTransactionListener (Si-6.16,M15)  1. OnTradeTransaction
2016.06.09 14:51:50.872 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_REQUEST
2016.06.09 14:51:50.872 TradeTransactionListener (Si-6.16,M15)  2. OnTradeTransaction
2016.06.09 14:51:50.872 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: Position  #0  Si-6.16 modified: SL=62000.00000 TP=67000.00000
Закрытие позиции (продажа)
2016.06.09 14:52:24.063 TradeTransactionListener (Si-6.16,M15)  1. OnTradeTransaction
2016.06.09 14:52:24.063 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_ORDER_ADD order #49118750 ORDER_TYPE_SELL ORDER_STATE_STARTED   
2016.06.09 14:52:24.067 TradeTransactionListener (Si-6.16,M15)  2. OnTradeTransaction
2016.06.09 14:52:24.067 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_REQUEST
2016.06.09 14:52:24.067 TradeTransactionListener (Si-6.16,M15)  MqlTradeResult: order #49118750  retcode=TRADE_RETCODE_PLACED 
2016.06.09 14:52:24.067 TradeTransactionListener (Si-6.16,M15)  3. OnTradeTransaction
2016.06.09 14:52:24.067 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_ORDER_UPDATE order #49118750 ORDER_TYPE_SELL ORDER_STATE_REQUEST_ADD   
2016.06.09 14:52:24.071 TradeTransactionListener (Si-6.16,M15)  4. OnTradeTransaction
2016.06.09 14:52:24.071 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_ORDER_UPDATE order #49118750 ORDER_TYPE_SELL ORDER_STATE_PLACED   
2016.06.09 14:52:24.073 TradeTransactionListener (Si-6.16,M15)  5. OnTradeTransaction
2016.06.09 14:52:24.073 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_DEAL_ADD deal #6945378 DEAL_TYPE_SELL Si-6.16 1.00 lot   (MOEX deal=185290646)
2016.06.09 14:52:24.075 TradeTransactionListener (Si-6.16,M15)  6. OnTradeTransaction
2016.06.09 14:52:24.075 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_ORDER_DELETE order #49118750 ORDER_TYPE_SELL ORDER_STATE_PLACED   
2016.06.09 14:52:24.077 TradeTransactionListener (Si-6.16,M15)  7. OnTradeTransaction
2016.06.09 14:52:24.077 TradeTransactionListener (Si-6.16,M15)  MqlTradeTransaction: TRADE_TRANSACTION_HISTORY_ADD order #49118750 ORDER_TYPE_SELL Si-6.16 ORDER_STATE_FILLED   (MOEX ticket=3377182821)

 
Rashid Umarov:

There is an example of an owl that listens to TradeTransaction events in the article How to Start Creating a Trading Robot for the Moscow Exchange MOEX

Try to run it and see the logs of trade operations. Any questions should go away.

Thank you very much.

I just want to know the gist of it:

Will you fix it?

 
Karputov Vladimir:

The scheme is as follows:

  1. You set a pending order, set the volume of the order in the m_volume variable
  2. When TRADE_TRANSACTION_DEAL_ADD is received, compare the position volume with m_volume variable and check if the initial order still hangs there (maybe it was a partial execution and you added the volume manually).

Karputov Vladimir how to dance with tambourine I (approximately) know....
 

prostotrader:

Only, I would like a substantive answer:

Will you correct the error?

I'm sorry to barge in again... but let me ask you, what is the mistake?
 
Dennis Kirichenko:
I'm sorry to barge in again... but let me be clear, what is the mistake?
That's what I was going to write.
 
prostotrader:

Thank you very much.

Only, I would like a substantive answer:

Will you correct the error?

Then you don't need the example - all the stages of trade order execution are clearly spelled out there. You haven't even looked at it:

 MqlTradeTransaction: TRADE_TRANSACTION_DEAL_ADD deal #6945344 DEAL_TYPE_BUY Si-6.16 1.00 lot   (MOEX deal=185290434)
 
Rashid Umarov:

So you don't need the example - it clearly spells out all the stages of trade order execution. You haven't even looked at it:

You haven't even looked!!!

MQ Alexander 2016.08.03 18:00 #      EN
Что касается ордеров, позиций и сделок.

Как написано в хелпе - последовательность поступления транзакций не гарантирована - транзакция переноса ордера в историю может быть получена раньше, чем транзакция сделки.
Изменение позиции в терминале происходит строго в результате получения сделочной транзакции, соответственно её получение является гарантией того что позиция поменялась.
Получение транзакции переноса ордера в историю, гарантирует только то, что ордер перестал быть активным (открытым) и был перенесён в историю ордеров.



Кроме того, транзакции могут потеряться при доставке от сервера к терминалу.
Что касается этой фразы. 

Судя по всему - она осталась из документации к одной из начальных версий терминала с асинхронной торговли. В ближайшее время уберём. Виновные будут расстреляны.

 
prostotrader:

You haven't even looked at it!!!

TRADE_TRANSACTION_DEAL_ADD is all yours. Until you get this event - the position information may be false. Everything else is just your idea of how it works. Wants, in other words.

Wait for TRADE_TRANSACTION_DEAL_ADD, then get position information. That's it.

 
Karputov Vladimir:

TRADE_TRANSACTION_DEAL_ADD is your everything. Until you receive this event - the position information may be false. Everything else is just your idea of how it works. Wants, in other words.

Wait for TRADE_TRANSACTION_DEAL_ADD, then get position information. That's it.

I have already told you:

How to dance with the tambourine I (roughly) know.

Reason: