void CloseAll() {
int total =OrdersTotal();
for(int i=total;i>=0;i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
int type = OrderType();
if (type == OP_BUY) {OrderClose(OrderTicket(), OrderLots(),NormalizeDouble(OrderClosePrice(),Digits), 5, Blue );}
if (type == OP_SELL) {OrderClose(OrderTicket(), OrderLots(),NormalizeDouble(OrderClosePrice(),Digits), 5, Red );}
}
return(0);
}
เอา module นี้ไปไว้ล่างสุด แล้วเรียกใช้เมื่อตรงตามเงื่อนไขเลยครับ
