Hi all,
I’m trying to convert my EA from MT4 to MT5 and am not sure how to loop through open positions and close them if necessary. In MT4 I did something like this:
void ProcessOrders() {
int TotalOrders = OrdersTotal();
bool OrderClosed = false;
for(int PositionIdx = TotalOrders - 1; PositionIdx >= 0; PositionIdx --) {
if (OrderSelect(PositionIdx,SELECT_BY_POS)==true) {
OrderClose = CloseOneOrder(OrderTicket());
}
}
Read more: http://forums.babypips.com/newbie-island/53341-what-scope-orderselect-function-mql4.html#ixzz2uJcJZpsH
Now in MT5 it is a bit different. Is the function “PositionsTotal” in MT5 same as OrdersTotal() in MT4. I’m a bit confused any suggestion welcome.