Peter Kaiza:
I'm trying to convert this code from mql4 to Mql5 but id does return the desired result;
What is the mistake?
Hey Peter, am having the same problem, did you get the solution ?
David Muriithi:
Hey Peter, am having the same problem, did you get the solution ?
There is a difference between deals, orders, and positions in MQL5. You need to use the position functions to work with open positions. Even better, use the CPositionInfo class.
#include <trade/trade.mqh> int OnInit() { return INIT_SUCCEEDED; } void OnTick() { CPositionInfo pos_info; string comment = ""; for (int i=PositionsTotal()-1; i>=0 && pos_info.SelectByIndex(i); --i) { comment += StringFormat( "\nIndex=%d, Symbol=%s, Ticket=%d, Type=%s, Profit=%.2f", i, pos_info.Symbol(), pos_info.Ticket(), EnumToString(pos_info.PositionType()), pos_info.Profit() ); } Comment(comment); }
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
I'm trying to convert this code from mql4 to Mql5 but id does return the desired result;
What is the mistake?