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

 
Andrey Dik:

First of all, why go through the story if the position is the last?

Because the order of the history depends on the sorting in the history tab.
 
Combinator:
Then that the order of history depends on the sorting in the history tab.
I think I once tested this hypothesis. It was not confirmed.
 
Combinator:
Then that the order of the history depends on the sorting in the history tab.
No, it doesn't. Yesterday I was sorting in every way, fiddling so as not to miss.
 
Andrey Dik:

First of all, why go through the history if the position is the last one? No one ever looks for, for example, the "last" element of an array.

Second, the question was about the way to determine if the position was closed by SL or TP. At the moment the most adequate and most reliable way is to read the comment. In addition, the argument that the broker can change the comment relating to SL and/or TP is at the level of fiction, I have not met examples of such brokers, neither personally, nor by hearsay from anyone. i.e. someone somewhere heard something from someone, but no one personally saw the fact.

OnTradeTransaction() is not guaranteed, which means that it can be used as an informational source and nothing more. Not a tool for management and decision making in trade operations.

But no one can claim that the last trade in the history of MT5 will definitely be a position closing trade. Especially if there are 2 Expert Advisors working on an account.

As for the comment on the position\order, the argument "from the realm of fantasy" or "everyone is doing it" are the most unconvincing arguments.
 
Alexey Viktorov:

But no one can claim that in the history of MT5 the last deal will definitely be a position closing deal. Especially if there are 2 Expert Advisors working on the account.

It is true, but sometimes the SL/TP data still requires going through the history. I do not understand why we may need the information whether the last deal was closed in SL/TP? I.e. why would I need it in OnTradeTransaction, although the trigger was somehow published.

And here, for example, how it may be necessary to have information about SL/TP - I understand.

 
fxsaber:

That's right, but the SL/TP data sometimes needs to go through the history. I don't understand what the information may be needed to know if the last SL/TP trade was closed? I.e., why should I fetch it in OnTradeTransaction, although the trigger was somehow published.

But, e.g., I understand how we may need information on SL/TP sliding.

It's a very common condition of various strategies.

As an example: there is a signal to buy - if the last closed position was to buy, and it was closed on the take, then do not open any more purchases until the "starting" condition for waiting for the signal occurs (for example - the price should first cross a certain value, and only after that should react again to the signal to buy). If the position was closed, but not on the take value (for example, on the trail), then you can open a position to buy without waiting for the "starting" condition.

Well... I can think of many different ways for which people use the knowledge that a position is closed by a stop order.

 
Artyom Trishkin:

It's a very common condition of different strategies.

As an example: there is a buy signal - if the last closed position was a buy position, and it was closed on the take, then do not open more purchases until ...

I do not want to offend anyone, but this condition is idiotic. Maybe freelancing is not that bad.
 
fxsaber:

That's right, but the SL/TP data sometimes needs to go through the history. I don't understand what the information may be needed to know if the last SL/TP trade was closed? I.e. why would I need it in OnTradeTransaction, although the trigger was somehow published.

And here, for example, I see how we may need information on SL/TP slippage.

Pulling the history of orders and deals on a position ticket does not mean going through the history of orders and deals for some period or for the whole history in search of the last closed position.

For what purpose the position was closed by TP or SL, I do not understand either, the main thing is with a profit or with a loss. After all, it all comes down to this. The further decision is taken according to this, closing at TP means a profit. But sometimes it's not taken into account that you may also make profit if you close on the SL.

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

 
Artyom Trishkin:

It is a very common condition in various strategies.

As an example: there is a signal to buy - if the last closed position was to buy, and it was closed on the take, then do not open more purchases until there is a "starting" condition for waiting for the signal (for example - the price must first cross a certain value, and only after that should react again to the signal to buy). If the position was closed, but not on the take value (for example, on the trail), then you can open a position to buy without waiting for the "starting" condition.

Well... I can think of a lot of different ways people use the knowledge that a position has been closed by a stop order.

Although it's a rare case, but convincing. The question is whether it is necessary to investigate the history to any great depth?
 
Alexey Viktorov:
Although rare, but convincing. The whole question is whether it is necessary to dig any depth in history?
No, you don't. You just need to know how the last position was closed (and for this, there is no need to delve too deeply into the history - it is enough to filter "friendly" deals) - the knowledge further to the last position deep into the history is more statistical than operational.