//+------------------------------------------------------------------+ void CheckForCloseBuy() { if (OrdersTotal() > 0) { for (int i = OrdersTotal() - 1; i >= 0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) != FALSE) { if (OrderType() == OP_BUY) { OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 30, White); Sleep(5000); } } } } } void CheckForCloseSel() { if (OrdersTotal() > 0) { for (int i = OrdersTotal() - 1; i >= 0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) != FALSE) { if (OrderType() == OP_SELL) { OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 30, White); Sleep(5000); } } } } } //======================================== int start() { CheckForCloseBuy(); CheckForCloseSel(); return (0); } //===================