Discussion of article "Processing of trade events in Expert Advisor using the OnTrade() function"

MetaQuotes  

New article Processing of trade events in Expert Advisor using the OnTrade() function is published:

MQL5 gave a mass of innovations, including work with events of various types (timer events, trade events, custom events, etc.). Ability to handle events allows you to create completely new type of programs for automatic and semi-automatic trading. In this article we will consider trade events and write some code for the OnTrade() function, that will process the Trade event.

Figure 1. Alerts

Author: KlimMalgin

Filip  

Hi ,


thanks for writhing this aritce... I played a litte around with your code. But at first I have the basic problem, that I am worling with positions. That means:

My EA is setting a buyorder in the backtest  and the Ontrade function is called several times as described. But your code is only checken OrdersTotal. The strange thing is: the result of this function is always 0. After placing my Order I only have a Buy position, which is not handled of your code, isnt it ?

Whats wrong here?