jeudi 20 janvier 2011

Fermer tous les ordres

Ce programme ferme immédiatement tous les ordres, qu ' ils soient passés ou en attente.
bool vrai = true;

int start()
  {
   int dath = Hour();
   if (dath > 20)
    {
     int i = OrdersTotal() - 1;
     while (i >= 0)
      {
       OrderSelect(i, SELECT_BY_POS);
       int type = OrderType();
       if (type == OP_BUY)
        {
     OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 2);
        }
       if (type == OP_SELL)
        {
     OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 2);
        }
       if (type == OP_BUYLIMIT || type == OP_BUYSTOP || type == OP_SELLLIMIT || type == OP_SELLSTOP)  
        {
         OrderDelete(OrderTicket());
        }
       i -= 1  // décrémentation i = i - 1
      }
    }
return;
}

Aucun commentaire:

Enregistrer un commentaire