StopLoss is for none belivers... Trust the Gurus..
Closing all trades? 15 replies
Closing multiple positions at the same time 5 replies
Closing Multiple lots with EA 1 reply
closing of trades 4 replies
About closing a position 3 replies
for (int i = 0;i < OrdersTotal();i++) { // check there are trades available if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; // check order type and close accordingly if(OrderType() == OP_BUY) { OrderClose(OrderTicket(),OrderLots(),Bid,3,White); } else if (OrderType() == OP_SELL) { OrderClose(OrderTicket(),OrderLots(),Ask,3,White); } }
for (int i = 0;i < OrdersTotal();i++) { // 1st level (opened order) Select OrderSelect(i,SELECT_BY_POS); string PairSym = OrderSymbol(); if(OrderType() == OP_BUY) { for(int o = 0;o < OrdersTotal();o++) { if(OrderSymbol() != PairSym) continue; // 2nd level to select the pending opponent if(OrderType() == OP_SELLSTOP && OrderSymbol() == PairSym) OrderDelete(OrderTicket(),White); } } if (OrderType() == OP_SELL) { for(o = 0;o < OrdersTotal();o++) { if(OrderSymbol() != PairSym) continue; // 2nd level to select the pending opponent if(OrderType() == OP_BUYSTOP && OrderSymbol() == PairSym) OrderDelete(OrderTicket(),White); } } }