Close order crossing the middle Bollinger Bands

 

Sometimes the price peak of a volume cross the middle Bollinger Bands but the closing action doesn't trigger

This is my funtion for the Order Close:

void CloseOrder(){
   
   if(OrderSelect(ticketB,SELECT_BY_TICKET,MODE_TRADES)){
   
      bool ClosedB;
      
      if(Bid > iMA(NULL,PERIOD_CURRENT,20,1,MODE_SMA,PRICE_CLOSE,1) && !AvailableB){
      
         if(OrderCloseTime() == 0){
         
            ClosedB = OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),5);
            AvailableB = true;
         
         }
         else
            AvailableB = true;

      }
   }
   
   if(OrderSelect(ticketS,SELECT_BY_TICKET,MODE_TRADES)){
        
      bool ClosedS;
             
      if(Ask < iMA(NULL,PERIOD_CURRENT,20,1,MODE_SMA,PRICE_CLOSE,1) && !AvailableS){
               
         if(OrderCloseTime() == 0){
         
            ClosedS = OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),5);
            AvailableS = true;
         
         }
         else
            AvailableS = true;
         
      }
   }
}
 
Lagger2807:

Sometimes the price peak of a volume cross the middle Bollinger Bands but the closing action doesn't trigger

This is my funtion for the Order Close:

What is " price peak of a volume" ?

Where is the value of AvailableB set?

 ClosedB = OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),5);
            AvailableB = true;

//Can't you simply use
 AvailableB = OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),5);
 
Keith Watford:

What is " price peak of a volume" ?

Where is the value of AvailableB set?

The highest(or Lowest) price of a candle and AvailableB is a global variable i need for another functions
 
Lagger2807:
The highest(or Lowest) price of a candle and AvailableB is a global variable i need for another functions

I should have asked, where is AvailableB,s value being set beforethe function is called.

If it already == true the order will not be closed.

 
Keith Watford:

I should have asked, where is AvailableB,s value being set beforethe function is called.

If it already == true the order will not be closed.

AvailableB were set in the ordersend, when the order is sended, AvailableB sets to false