Best way to close a lot of positions?

 

Hi,

I using this function to close all my position:

   for (int i = OrdersTotal() - 1; i >= 0; i--) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol()) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
            if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, 3, Blue);
            if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red);
         }
         Sleep(750);
      }
   }

Probably the problem is the Sleep(750), each position is closed only after nearly 1 seconds after the position before, thats a lot of time, if I have 50 or more positions to close.

Its a good idea to delete the sleep?

For a better solution I would be very grateful.

 
Better solution: remove the sleep xD