Deleted order was not deleted?

 

I have a question for OrderDelete(). It would be very appriciated if anyone could help me.

My code deletes the following pending order of OP_SELLSTOP:

>2009.07.05 15:55:34 2009.06.23 09:12 test GBPJPY,M1: delete #9 sell stop 0.10 GBPJPY at 154.10 sl: 164.10 tp: 152.99 ok

After then, executing the following code:


for(in cnt=0;cnt < OrdersTotal();cnt++){
  OrderSelect(cnt,SELECT_BY_POS);
  if(OrderType()==OP_SELLSTOP)||OrderType()==OP_BUYSTOP){
    OrderDelete(OrderTicket());
  }

}

and the result is the following:

>2009.07.05 15:56:53 2009.06.23 09:15 test GBPJPY,M1: OrderDelete error 4108

>2009.07.05 15:56:53 2009.06.23 09:15 test GBPJPY,M1: unknown ticket 9 for OrderDelete function

The question is why the deleted order is selected by OrderSelect().

Maybe I misunderstand the function, but I don't know.

I would like not to select deleted order in the case.




 

I'd recommend first of all, that you count DOWN in your loop rather than up.


CB

 
cloudbreaker:

I'd recommend first of all, that you count DOWN in your loop rather than up.


CB

Hi CB,

Thank you for the advice, I will try.

Meanwhile, I tried combination use of OrderCloseTime()==0 and this seemed good so far.

(But  I still don't know the underlying cause...)


hug

Reason: