Operator While - until open trades

 

Hello, I am trying code EA with operator while. Cycle until are open trades, but my code not working. Can me anybody advice ?

Here is code.   Thank you

int start(){    
  


   while(ExistPositions() == True)
     {
      do something
     }
     else
     {
     continue;
     }


return(0);

bool ExistPositions() {
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol()) {
return(True);
}
} 
} 
return(false);
}
 

It doesn't work because nothing is changing.

If it is NOT time to do something, RETURN (thus waiting for the next tick)

int start(){    
  


// while(ExistPositions() == True)
   if(ExistPositions())
     {
      do something
     }
//     else
//     {
//     continue;
//     }


return(0); // Wait for next tick
Reason: