I placed to pending orders , the Problem in Deleting a pending order when the other is activated

 

I have been trying many ways this is the last one 


Can you please show me why is wont work ?

for(int i=0; i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
{
if(OrderMagicNumber() == 001) 
{
 if(OrderType() == OP_SELL || OrderType() == OP_BUY)
 
 {delete_pendings();}
}
}
}


// -------------


  void delete_pendings()
     {
     for(int i=0; i<OrdersTotal();i++){
     OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
     if(OrderMagicNumber() == 001)
     {
     if(OrderType() == OP_BUYSTOP || OrderType() == OP_SELL)
     {OrderDelete(OrderTicket());}
     
     }
     }}
 
There are four types of pending. A Sell is not one of them.
 
for(int i=0; i<OrdersTotal();i++)

Count down, not up when deleting.orders.

for(int i=OrdersTotal-1; i>=0);i--)
if(OrderType() == OP_BUYSTOP || OrderType() == OP_SELL)

OP_Sell is not a pending order.

Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.

 
  • I discovered the location of the default but I dont see what's wrong ...
  • I wrote simple Comment() to show me where I am in the process 
  • when the activated order is (the SELL ) type ... it works well
  • bit when the activated order is the (Buy) it never passes the  ""on tick selecting "" stage 
 
William Roeder:
There are four types of pending. A Sell is not one of them.

I am really sorry !! thank you very much did not notice it 

 
Keith Watford:

Count down, not up when deleting.orders.

OP_Sell is not a pending order.

Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.

thank you very much did not notice it the (OP_SELL) there ... sure I used the i-- .. but as I said I did not notice the OP_SELL there (BIG thanks )