With what to replace OnTradeTransaction() in mql4?

 

Actually, this is my question. I am using MT5 for a long time, but I have to use MT4 for some reason. But mql4 has no OnTrade() and OnTradeTransaction() what is very sad.

Therefore, I have to solve the problem with a small cost (in terms of resources).

So far, I have not thought of anything better than going through the open orders and comparing the current state with the previous one.

Perhaps there are more reasonable solutions.

 
This is exactly the most reasonable solution. And it is the most reasonable one for MT5 as well, because one cannot rely only on OnTrade() and OnTradeTransaction(). They are not guaranteed.
 
Aleksandr Volotko:

Actually, this is my question. I am using MT5 for a long time, but I have to use MT4 for some reason. But mql4 has no OnTrade() and OnTradeTransaction() what is very sad.

Therefore, I have to solve the problem with a small cost (in terms of resources).

So far, I have not thought of anything better than going through the open orders and comparing the current state with the previous one.

Perhaps there are more reasonable solutions.

Not the easiest variant is to read articles by Artem Trishkin. And there are 31 or already 32 of them. I checked and communicated with him about it. All of the events are caught "with a bang".

Of course, if you don't try to get into the essence of the contents of its codes, it should be easier.


ps; Oh... just got back from this thread and the discussion thread on the 32nd part of the article caught my eye immediately. The article itself is here.

Обсуждение статьи "Библиотека для простого и быстрого создания программ для MetaTrader (Часть XXXII): Отложенные торговые запросы - установка ордеров по условиям"
Обсуждение статьи "Библиотека для простого и быстрого создания программ для MetaTrader (Часть XXXII): Отложенные торговые запросы - установка ордеров по условиям"
  • 2020.01.24
  • www.mql5.com
Опубликована статья Библиотека для простого и быстрого создания программ для MetaTrader (Часть XXXII): Отложенные торговые запросы - установка орде...
 

Igor is right, it's hard to come up with something smarter and simpler at the same time, because any other solution will be based on the same call to OrdersTotal() with filtering orders according to taste and further date processing.

I'll stop here for now, it will do for my problem.

 
Ihor Herasko:
This is exactly the most reasonable solution. And it is the most reasonable one for MT5 as well, because one cannot rely only on OnTrade() and OnTradeTransaction(). They are not guaranteed.

It must have been a long time since you were interested in it. The notion that a transaction may be lost was removed from the documentation a long time ago. So, for mql5 there is nothing better than OnTradeTransaction(). I have checked the speed of getting the event of pending order activation in OnTradeTransaction() and via Artem's library. OnTradeTransaction() is faster. I have not measured it. I have to make more measurements to make a fair estimate but I didn't want to spend time on it.

 
To be fair, I've never had any problems with OnTradeTransaction() on MT5, everything was always smooth. No losses.
 
Alexey Viktorov:

You probably haven't looked into this for a very long time. They removed the caveat that transaction can get lost from documentation a long time ago. So, there is nothing better than OnTradeTransaction() for mql5. I have checked the speed of getting the event of pending order activation in OnTradeTransaction() and via Artem's library. OnTradeTransaction() is faster. I have not measured it. I have to make more measurements to make a fair estimate but I was too greedy to spend time on it.

It's natural - I have set frequency of environment scanning. Therefore, the fact of the event itself in the terminal and the fact of environment change follow each other. But the fact of change of the environment is caught, not the arrival of the event. This has its merits. But you deny them anyway ;) So there is no point in debating.
 
Artyom Trishkin:
It's only natural - I have a set frequency for scanning the environment. Therefore, the fact of the event itself in the terminal and the fact of environment change follow each other. But with me it is the fact of environment change that is caught, not the arrival of the event. This has its merits. But you deny them anyway ;) So there is no point in debating.

What pluses am I in denial about? I have only one denial. I want to understand how things work, and if it's only possible to understand things not my mind, then I'm not comfortable using them, and anything I'm not comfortable with I deny. I've already told you that you write more letters than I can read for the rest of my life. Don't you take it out on me...

 
Ihor Herasko:
This is exactly the most reasonable solution. And it is the smartest one for MT5 as well, because one cannot rely only on OnTrade() and OnTradeTransaction(). They are not guaranteed.

You are hopelessly behind the times!

For a long time these events have been guaranteed!

 
Communication failure during (after) execution of OrderSend (-Async) - loss of OnTrade*.
 
prostotrader:

You are hopelessly behind the times!

These events have been guaranteed for a long time!

And the availability of lights and internet? Not to mention the usual network packet loss. How cool MetaQuotes have become - they guarantee everything! ))