Open another trade after trend goes back into bollinger band range

 

Hey guys, I'm trying to program an EA to trade based off of bollinger band breakouts. Once it hits the TP it will immediately open another trade if the initial conditions are met for opening the trade. I'm trying to make sure that the trend goes back inside the range of the bollinger bands before opening another trade. I have a variable "check" to see if it has gone back inside the bollinger band range before it opens another trade but it isn't working properly. The logic for the check is in the last if statement. Thanks

 

  if(check&&Bars>BarCount&&!OrderSelect(0,SELECT_BY_POS))   //Beginning of loop to open trade if conditions are met
  {
      if(Close[1]>KUpper&&Close[1]>Upper1)   //Buy Logic
      {
         Ticket=OrderSend(NULL,OP_BUY,Lot,Ask,10,BuySL,BuyTP,NULL,Magic,NULL,clrBlue);
        // Ticket1=OrderSend(NULL,OP_BUY,Lot,Ask,10,BuySL,NULL,NULL,Magic,NULL,clrBlue);
        BarCount=Bars;
        check=false;
         
         Position=1;   //Sets Position to Buy
         
      }
      if(Close[1]<KLower&&Close[1]<Lower1)   //Sell Logic
      {
         Ticket=OrderSend(NULL,OP_SELL,Lot,Bid,10,SellSL,SellTP,NULL,Magic,NULL,clrRed);
        // Ticket1=OrderSend(NULL,OP_SELL,Lot,Bid,10,SellSL,NULL,NULL,Magic,NULL,clrRed);
        BarCount=Bars;
        check=false;
         
         Position=2;   //Sets Position to Sell
      }

      
   }
   if(!OrderSelect(0,SELECT_BY_POS)&&(Close[1]>KLower||Close[1]>Lower1||Close[1]<KUpper||Close[1]<Upper1))check=true; //Check to see if previous bar closed inside bollinger range after trade closed