what's wrong here (orderselect)

 

I'm tring to use orderclose/ordermodify. I think before use that, I need to use orderselect. I have this code:


if (condition1)

{
OrderSend(OP_BUY...)
}

for(int i=OrdersTotal();i>0;) // this is for select order if there are orders opened
{
OrderSelect(OrdersTotal(), SELECT_BY_POS,MODE_TRADES);
}

if (condition2)
{
OrderClose(...)

}


What's wrong in this code?


Thanks a lot

trader201

 

for(int i=orderstotal(); i>0; i--)


--> orderselect(i, select_blablabla)

 

It will be right:

for(int i=orderstotal()-1; i>=0; i--)


--> orderselect(i, select_blablabla)