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

 
Alexey Viktorov:

I'm not doing anything yet. Even in mql4 I found it useless to look through the history of orders. And here I'm still fantasizing in what direction I would start digging if necessary. A little earlier, I said that I could not check it for the simple reason: I have no trailed positions in any terminal and do not want to do it specially.

Accordingly, after closing the position, there are only 2 orders and 2 deals referring to the position on my accounts. Using them, we may get at least some information about the position. For example, at what price the request was opened and at what exactly it was opened. Accordingly, it is easily determined by the slippage at which the position was opened.

I treat the commentary with caution since MT4 because there were cases when brokerage companies wiped the comments according to their own reasons.

I see, you are guessing, I have a proven solution.

Moderator Artem, unnecessary posts, and some of mine too, can already be annihilated.

 
Artyom Trishkin:

In general, of course, it's difficult to quickly switch to the logic of the MT5 order system after the four.

Start writing the MT4->MT5 converter, and everything will fall into place. That's how I got a very good understanding of what things can ONLY MT4, what things can ONLY MT5, what things can none of them.

For example

  • MT5 cannot show SL/TP at the time of closing a position. MT4 can.
  • MT4 cannot show slippage of orders, MT5 can(not always).
  • MT4 cannot give comment at close, MT5 can.
  • In MT4/5 it is not possible to change pending orders with a magic, comment and volume.
  • There is no requested price property in MT5, much less in MT4.
  • ...
 
Andrey Dik:

I see, on the level of conjecture you have, and I gave a proven solution.

Moderator Artem, unnecessary posts, and some of mine too, can already be annihilated.

At the level of speculation as you do not. I determine everything for myself at the moment of position opening/closing from the OnTradeTransaction() function and there is no need to look through the history to find the last closed/open position.
 
Alexey Viktorov:
There is no need to do it on a guessing level. I determine everything for myself at the moment of position opening/closing from function OnTradeTransaction() and there is no need to look through the history to find the last closed/open position.
And here a question arises: is it always possible to obtain the necessary information in time? Especially after reading the help...
 
Andrey Dik:

I see, on the level of conjecture you have, and I gave a proven solution.

Moderator Artem, unnecessary posts, and some of mine too, can already be annihilated.

Why to delete? Normal discussion - all on topic.
 
Artyom Trishkin:
Why delete? It's a normal discussion - everything is on topic.
Yes, originally you and I assumed the essence of the branch quite differently. There shouldn't be any reasoning here... And there should be no questions. And only brief "chips". Believe me, those who are already writing in mql5 are not interested in reading most of what is written here.
 
Artyom Trishkin:
And then the question arises: is it always possible to get the right information in time? Especially after reading the help...
Maybe not always at exchanges and when using OrderSendAsync(). But for forex, so far I obtained it whenever the OnTradeTransaction event occurs. It is absolutely easy to detect position opening, pending order activation and position closing. Here a counter question arises: Is it necessary to search through the history for the last closed position if we can catch the very fact of closing?
 
Alexey Viktorov:
For example, I can use OrderSendAsync() in forex, but not always. But for Forex, so far I always get it when OnTradeTransaction event occurs. It is absolutely easy to detect position opening, pending order activation and position closing. Here a counter question arises: Is it necessary to search through the history for the last closed position if we can catch the very fact of closing?

First, why search through the history, if the position was last closed? No one ever looks for, for example, the "last" element of the array.

Second, the question was about the way to determine whether a position is closed on SL or TP. At the moment, the most adequate and most reliable way is reading the comment. In addition, the argument that a 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 hears something from someone, but no one has personally seen the fact.

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

 
Andrey Dik:

***

OnTradeTransaction() is not guaranteed, **


Outdated information. The phrase that this event is not guaranteed has already been removed from the help.
 
Vladimir Karputov:
Outdated information. The phrase that this event is not guaranteed has already been removed from the reference.
This does not make it guaranteed