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

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The OnChartEvent is used in the article Creating Active Control Panels in MQL5 for Trading.
I mean : OnTrade()
should be OnTrade( id, para1,para2.....)
Could someone please improve the code given in the article to process the event of closing a position by stop loss or take profit?
Has it turned out to be unnecessary for the last 2.5 years since the publication of the article?
It is recommended to translate https://www.mql5.com/en/articles/211 Orders, Positions and Deals in MetaTrader 5.
Firstly, you need to find out which of the 6+2 above corresponds to Orders, Positions and Deals!
for MQL4, what can you think of that would be similar to OnTrade?
Check on each tick OrdersTotal() and OrdersHistoryTotal() - if the figure has changed - call OnTrade().
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?
for MQL4, what can you think of that would be similar to OnTrade?
Generate OnChartEvent() before making a trade operation, and in it try to get the result of the trade operation.... And you can think of a type, according to which OnChartEvent() should be called the necessary number of times...
If there are no graphic elements, why do we need such a variant? In my opinion, it's unnecessary...