4051 ,1 errors,etc - page 2

 
pascalboy:

Hi Raptor,

I am unable to erase pending orders.

I tought about the cycle but no errors.

Why ?

Read your code, see what you are doing . . go through it line by line and see what is wrong . . . don't assume it is correct and throw your hands up in the air because it doesn't work.

///////////////////////////////////////
//IF THERE ARE MARKET ORDERS 
for(int i = OrdersTotal(); i <= 1; i--)   //  this loop is wrong . . . 
{
   if(OrderSelect(i,SELECT_BY_POS))
      if (OrderType()==OP_BUY || OrderType()==OP_SELL)   //  only run the following code if the order is NOT a pending order . . .
      {
         Print(".............",OrderType());
                //IF THERE ARE OP_BUYSTOP OR OP_SELLSTOP ORDERS 
         for(i=OrdersTotal();i<=1;i--)
            if(OrderSelect(i,SELECT_BY_POS))
//ERASE LAST SELECTED PENDING  ORDER 
               if(OrderType()==OP_BUYSTOP )
               int OpBuySilinecekEmirNumarasi=OrderTicket();
               OrderDelete(OpBuySilinecekEmirNumarasi);  
               if(OrderType()==OP_SELLSTOP)   
               int OpSellSilinecekEmirNumarasi=OrderTicket();
               OrderDelete(OpSellSilinecekEmirNumarasi);   
      }
}
Reason: