Order select for MQL5
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 ?
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); }
I'm trying to convert this code from mql4 to Mql5 but id does return the desired result;
What is the mistake?