something wrong ? : OrderSelect error

 

Hi everybody

 

i've written this cycle code but i don't know why an error always happens:

 the code:

  for(index=OrdersTotal();index>=0;index--){
              if (OrderSelect(index,SELECT_BY_POS)==true){ 
                  if (OrderType()==OP_BUY && MarketInfo(Symbol(),MODE_POINT)>upBB){ 
                                                   Print ("LIMIT up bollinger");
                                                   CloseBuyOrders(Magic);}
                   if (OrderType()==OP_SELL && MarketInfo(Symbol(),MODE_POINT)<loBB){ 
                                                   Print ("LIMIT down bollinger");
                                                   CloseSellOrders(Magic);}
                                                        }
                                                        
              else    Print("OrderSelect returned the error of ",GetLastError());                                       
                                                      }
   
        
                     }          

 

and this is the error:

 2012.12.22 11:31:17 2012.12.20 23:59  rsibolinger2 EURUSD,M1: OrderSelect returned the error of 0

could you help me please?

 

thanks a lot and merry christmas 

 
cond3mn3d:

Hi everybody

i've written this cycle code but i don't know why an error always happens:

 the code:


and this is the error:

 2012.12.22 11:31:17 2012.12.20 23:59  rsibolinger2 EURUSD,M1: OrderSelect returned the error of 0

could you help me please?

thanks a lot and merry christmas 

That means the return of OrderSelect() is false. Try this :

for(index=OrdersTotal() - 1;index>=0;index--)

 Say you have 23 trades. OrdersTotal() will return 23, and you're not counting them from 1 to 23, but from 0 to 22. So there's no position number 23, and so OrderSelect() return false.

 
cond3mn3d:

Hi everybody

 

i've written this cycle code but i don't know why an error always happens:

 the code:

 

and this is the error:

 2012.12.22 11:31:17 2012.12.20 23:59  rsibolinger2 EURUSD,M1: OrderSelect returned the error of 0

could you help me please? 

Can you follow your indenting and  { }  braces ?  really ?   can you ?  if you can  . . .  why did you include the last brace which lies outside of the for loop ?  if you can't then you need to address this issue . . .
 

tks a lot phi.nuts , you are right! noiw it work!


4 raptor uk.

u are right i made a mistake when i copied the code! tks