Discussion of article "Creating an EA that works automatically (Part 08): OnTradeTransaction"

 

New article Creating an EA that works automatically (Part 08): OnTradeTransaction has been published:

In this article, we will see how to use the event handling system to quickly and efficiently process issues related to the order system. With this system the EA will work faster, so that it will not have to constantly search for the required data.

Now, in a much more complete way, we finally have the C_Manager class and the EA which are friendly with each other. Both can work and make sure they don't become aggressive or unfriendly. Thus, the message flow between the EA and the C_Manager class becomes as the one in Figure 02:

Figure 02

Figure 02. Message flow with new functions


This flow may seem too complicated or completely non-functional, but this is exactly what has been implemented so far.

Looking at Figure 02, you might think that the EA code is very complex. But it is much simpler than what many people consider to be a necessary code for an EA. Especially when it comes to an automated EA. Remember the following: The EA does not actually generate any trades. It is just a means or tool for communicating with the trade server. So it actually just reacts to triggers which are applied to it.

Author: Daniel Jose

 
OnTradeTransaction is great but I have a real issue.
I started to use it to catch events (opening a position, closing, modifying) as I did before in MT4 (checking constantly the positions to guess what happened). In that aspect, MT5 approach is very clean.
BUT WHAT HAPPENS IF THE EA IS DOWN or OFF DURING ONE HOUR : it will not receive any event of course but when it restart it will not get the events it messed during 1 hour. So to guess what happened it will need to do the old MT4 way by analysing the positions to guess what happened. To solve this issue I must keep the 2 ways to detect events : the MT5 way and the MT4 way as backup.
 
OnTradeTransaction is taking up to 5 seconds to detect events on pending orders (modification and deletion). Is this normal ?
For market positions it's immediate.
 
Gad Benisty #: OnTradeTransaction is great but I have a real issue. I started to use it to catch events (opening a position, closing, modifying) as I did before in MT4 (checking constantly the positions to guess what happened). In that aspect, MT5 approach is very clean. BUT WHAT HAPPENS IF THE EA IS DOWN or OFF DURING ONE HOUR : it will not receive any event of course but when it restart it will not get the events it messed during 1 hour. So to guess what happened it will need to do the old MT4 way by analysing the positions to guess what happened. To solve this issue I must keep the 2 ways to detect events : the MT5 way and the MT4 way as backup.

I agree... that's why during Expert Advisor startup, a check of positions or pending orders is done. But this is seen in an article a little further on in this same sequence.

Automated translation applied by moderator

 
Daniel Jose #:

Concordo ... por isto que durante a inicialização do Expert Advisor, é feita uma checagem das posições ou ordens pendentes. Porém isto é visto em um artigo um pouco mais a frente nesta mesma sequencia.

Please post in English on this forum.
 
Alain Verleyen # :
Please post in English on this forum.

Sorry... I forgot to tell the system to translate. 👍

Reason: