Features of the mql5 language, subtleties and tricks - page 23

 
Artyom Trishkin:
No, you don't. You just need to know how the last position was closed (and there is no need to go much deeper into the history for that - it is enough to filter "your" deals) - the knowledge of the last position deep into the history is more statistical than operative.
Well, all this is done in OnTradeTransaction. Only in the trigger published by fxsaber : I would add a check on the symbol, magician and trade on DEAL_ENTRY_OUT
Особенности языка mql5, тонкости и приёмы работы
Особенности языка mql5, тонкости и приёмы работы
  • www.mql5.com
В данной теме будут обсуждаться недокументированные приёмы работы с языком mql5, примеры решения тех, или иных задач...
 
Alexey Viktorov:
Well, all this is done in OnTradeTransaction. Only in trigger published by fxsaber : I would add a check on symbol, magician and trade on DEAL_ENTRY_OUT
And how would you check it in the tester?
 
Artyom Trishkin:
How will you check in the tester?
Same way. What is the difference? It's in the tester and debugger I was trying all this to understand how it works.
 
Alexey Viktorov:

I didn't look at this trigger carefully, but I didn't see any check for DEAL_ENTRY_OUT. After all, this is the deal that indicates the closing of the position on the accounts.

The check is not needed. The trigger will not work in the tester, because the tester does not generate some Trade-events.
 
fxsaber:
Verification is not needed. The trigger will not work in the tester, because the tester does not generate some Trade events.

Which ones, for example from this list?

TRADE_TRANSACTION_ORDER_ADD

Adds a new open order.

TRADE_TRANSACTION_ORDER_UPDATE

Modification of an open order. These changes include not only explicit changes from the client terminal or trade server but also changes of the order state when placing it (for example, from ORDER_STATE_STARTED to ORDER_STATE_PLACED or from ORDER_STATE_PLACED to ORDER_STATE_PARTIAL etc.).

TRADE_TRANSACTION_ORDER_DELETE

Deletion of an order from the list of open orders. Orders can be deleted from the list of the open ones as a result of a trade request or as a result of execution (filling) and transferring to history.

TRADE_TRANSACTION_DEAL_ADD

Adding a trade to the history. Carried out as a result of an order execution or an account balance operation.

TRADE_TRANSACTION_DEAL_UPDATE

Changing of a deal in the history. It is possible situations when a previously executed deal is changed on the server. For example, the trade was changed in the external trading system (exchange), where it was moved by the broker.

TRADE_TRANSACTION_DEAL_DELETE

Deletion of the trade from the history. There may be situations when a previously executed deal is deleted on the server. For example, the trade was deleted in the external trading system (exchange), where it was removed by the broker.

TRADE_TRANSACTION_HISTORY_ADD

Adding an order to the history as a result of execution or cancellation.

TRADE_TRANSACTION_HISTORY_UPDATE

Changing of an order located in the order history. This type is intended for expanding the functionality on the trade server's side.

TRADE_TRANSACTION_HISTORY_DELETE

Deletion of an order from the order history. This type is intended for functionality expansion on the trade server's side.

TRADE_TRANSACTION_POSITION

Change of a position not related to trade execution. This transaction type indicates that the position has been changed on the trade server side. The position's volume, opening price, as well as Stop Loss and Take Profit levels may be changed. Information about changes is transmitted to the MqlTradeTransaction structure through the OnTradeTransaction handler. A position change (addition, modification or elimination) as a result of a trade does not cause TRADE_TRANSACTION_POSITION transaction.

TRADE_TRANSACTION_REQUEST.

Notification that a trade request is processed by the server and the result is received. For transactions of this type it is necessary to analyze only one field - type (transaction type) in MqlTradeTransaction structure. The second and third parameters of OnTradeTransaction function (request and result) must be analyzed to get more information.


Unless the highlighted event is not generated. So, who needs it?

Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
Основы языка / Функции / Функции обработки событий - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Alexey Viktorov:

Such as from this list?

Trade event is my term.

Forum on trading, automated trading systems and trading strategies testing

Features of mql5 language, subtleties and tricks

fxsaber, 2017.02.28 19:30

There may be an open BUY position and an active BUY order. Above gave a code example, but probably easier on the fingers. How does TP of an open position trigger?

  • The price reaches the TP of the BUY position.
  • The trade server creates a corresponding active SELL order.
  • Thereafter, the terminal has simultaneously a BUY position and a SELL order.
  • The SELL order is executed by getting into history and generating a deal there.
  • The initial BUY position is closed on the basis of the deal data, but it does not get anywhere - it is indirectly present in the deal history.

The selected Trade-event does not occur in the tester.
 
fxsaber:

Trade-event is my term.

The highlighted Trade event does not occur in the tester.

In my opinion this is not an event. It is the subtleties of the order execution sequence. Why should I catch the moment when a SELL order to close a BUY position is in the terminal simultaneously with the position itself?

It may be a misfortune that the sequence of events may not be adhered to, but ... What is the main thing in trading? If they open a position for me even tomorrow, but at a stated price, and close it even yesterday, but with a profit, I will not object.

 
Alexey Viktorov:

In my opinion, this is not an event. It is the subtleties of the order execution sequence. Why should I catch the moment when a SELL order to close a BUY position is in the terminal at the same time as the position itself?

Read the title of this branch.
 
fxsaber:
Read the title of the thread.
What difference does it make?
 
Alexey Viktorov:
What will change?
Nothing will change, but the details have been described - no doubt about that.
And the question remains: how will this function catch the facts of closing at points/stops in the tester?
Reason: