Am getting an OrderSelect warning...Although the EA is compiling and trading and functioning properly, would like to have clean code as much as possible.
I've tried variations of fixing the code, but changes to the code have changed the way the EA closes trades. If any of you masters of MT4 can have a quick look, I'd like to try different approaches to this code, any suggestions?
I've tried variations of fixing the code, but changes to the code have changed the way the EA closes trades. If any of you masters of MT4 can have a quick look, I'd like to try different approaches to this code, any suggestions?
Inserted Code
void CLOSETRADES() { int totalorders = OrdersTotal(); for(int i=totalorders-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); bool result = false; { if (OrderMagicNumber() == Magic1) { if (OrderType() == OP_BUY && iOpen(NULL,1,0) > KEYPRICE ) result = OrderClose( OrderTicket(), OrderLots(), Bid, 50, Green ); if (OrderType() == OP_SELL && iOpen(NULL,1,0) < KEYPRICE ) result = OrderClose( OrderTicket(), OrderLots(), Ask, 50, Green ); } if (OrderMagicNumber() == Magic2) { if (OrderType() == OP_BUY && iOpen(NULL,1,0) > KEYPRICE ) result = OrderClose( OrderTicket(), OrderLots(), Bid, 50, Green ); if (OrderType() == OP_SELL && iOpen(NULL,1,0) < KEYPRICE ) result = OrderClose( OrderTicket(), OrderLots(), Ask, 50, Green ); } } } return; }