Difference at the exit point

 

Hello
I have a problem running a programming code .When I'm reviewing my programming code in strategy tester (Every tick) and real market , I see the difference in the result. I don't know ,why I have two exit points.
please guide me
Thanks


//Orders Counting & Close Orders------------------------------------+ 

   int orderscnt=0; 
for (int  i=OrdersTotal()-1 ; i>=0 ; i--) 
     { 
      //-------------------------------------- 
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES); 
      if((OrderSymbol()==Symbol()) && ((OrderType()==OP_SELL) || (OrderType()==OP_BUY))&& OrderMagicNumber()== MagicNumber) 
        { 
         orderscnt++; 
        } 

      //-Close Positione Buy if 
      if((OrderSymbol()==Symbol())  && (OrderType()==OP_BUY) &&  iBands(0,0,exite,1,0,PRICE_CLOSE,MODE_UPPER,1)<Close[1]) 
        { 
          OrderClose(OrderTicket(),OrderLots(),Bid,1,Black); 
      
     } 

      //-Close Positione Sell if  
      if((OrderSymbol()==Symbol()) && (OrderType()==OP_SELL) && iBands(0,0,exite,1,0,PRICE_CLOSE,MODE_LOWER,1)>Close[1]) 
        { 
         OrderClose(OrderTicket(),OrderLots(),Ask,1,Black); 
        } 
     }  
Reason: