sto scrivendo un ea per mt4. voglio inserire una condizione per chiudere i trade alternativa a quella presente: 
chiudi tutti i buy quando una candela chiude a ridosso della banda superiore di bollinger
chiudi tutti i sell quando una candela chiude a ridosso della banda inferiore

ci deve essere un bool per decidere se attivare questa modalità oppure no. 
questo il codice da aggiornare (riscrivilo per intero con le modifiche)
#property strict

// Input parameters
input int     bbPeriod        = 80;          // Bollinger Bands period
input double  bbDeviation     = 2.0;         // Bollinger Bands deviation
input int     rsiPeriod       = 5;           // RSI period
input double  rsiOverbought   = 80;          // RSI overbought level
input double  rsiOversold     = 20;          // RSI oversold level
input bool    aggressiveMode  = false;        // Aggressive mode boolean
input double  LotSize         = 0.1;         // Lot size for each trade
input int     Slippage        = 3;           // Maximum slippage
input bool    useStopLoss     = false;        // Use stop loss
input double  StopLossPips    = 150;         // Stop loss in pips
input bool    useTakeProfit   = false;        // Use take profit
input double  TakeProfitPips  = 200;         // Take profit in pips
input bool    useTrailingStop = false;        // Use trailing stop
input double  TrailingStop    = 10;          // Trailing stop distance in pips
input double  TrailingStep    = 5;           // Trailing step distance in pips

// Expert initialization function
int OnInit() {
    // Initialization code here
    return(INIT_SUCCEEDED);
}

// Expert tick function
void OnTick() {
    static datetime last_bar_time = 0;

    // Checking new bar
    if (Time[0] != last_bar_time) {
        last_bar_time = Time[0];
        
        double upper_band = iBands(NULL, 0, bbPeriod, bbDeviation, 0, PRICE_CLOSE, MODE_UPPER, 0);
        double lower_band = iBands(NULL, 0, bbPeriod, bbDeviation, 0, PRICE_CLOSE, MODE_LOWER, 0);
        double middle_band = iBands(NULL, 0, bbPeriod, bbDeviation, 0, PRICE_CLOSE, MODE_MAIN, 0);
        
        double rsi_current = iRSI(NULL, 0, rsiPeriod, PRICE_CLOSE, 0);
        
        // Check for Buy Condition
        if ((Close[1] < lower_band) || (aggressiveMode && Close[1] > middle_band && Close[2] <= middle_band)) {
            OpenBuyTrade();
        }
        
        // Check for Sell Condition
        if ((Close[1] > upper_band) || (aggressiveMode && Close[1] < middle_band && Close[2] >= middle_band)) {
            OpenSellTrade();
        }
        
        // Check for Close Buy Conditions
        if (rsi_current > rsiOverbought) {
            CloseBuyTrades();
        }
        
        // Check for Close Sell Conditions
        if (rsi_current < rsiOversold) {
            CloseSellTrades();
        }
    }
}

void OpenBuyTrade() {
    double stop_loss  = useStopLoss  ? NormalizedStopLoss(StopLossPips, OP_BUY) : 0;
    double take_profit= useTakeProfit? NormalizedTakeProfit(TakeProfitPips, OP_BUY) : 0;
    if (!OrderSend(Symbol(), OP_BUY, LotSize, Ask, Slippage, stop_loss, take_profit, "Buy Order", 0, 0, Blue)) {
        Print("Buy Order Send Error: ", GetLastError());
    }
}

void OpenSellTrade() {
    double stop_loss  = useStopLoss  ? NormalizedStopLoss(StopLossPips, OP_SELL) : 0;
    double take_profit= useTakeProfit? NormalizedTakeProfit(TakeProfitPips, OP_SELL) : 0;
    if (!OrderSend(Symbol(), OP_SELL, LotSize, Bid, Slippage, stop_loss, take_profit, "Sell Order", 0, 0, Red)) {
        Print("Sell Order Send Error: ", GetLastError());
    }
}

double NormalizedStopLoss(double pips, int op_type) {
    double stop_loss_price = 0;
    if (op_type == OP_BUY) {
        stop_loss_price = NormalizeDouble(Ask - pips * Point, Digits);
    } else {
        stop_loss_price = NormalizeDouble(Bid + pips * Point, Digits);
    }
    return stop_loss_price;
}

double NormalizedTakeProfit(double pips, int op_type) {
    double take_profit_price = 0;
    if (op_type == OP_BUY) {
        take_profit_price = NormalizeDouble(Ask + pips * Point, Digits);
    } else {
        take_profit_price = NormalizeDouble(Bid - pips * Point, Digits);
    }
    return take_profit_price;
}

void CloseBuyTrades() {
    for (int i = OrdersTotal() - 1; i >= 0; i--) {
        if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderType() == OP_BUY && OrderSymbol() == Symbol()) {
            if (!OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, clrNONE)) {
                Print("Close Buy Order Error: ", GetLastError());
            }
        }
    }
}

void CloseSellTrades() {
    for (int i = OrdersTotal() - 1; i >= 0; i--) {
        if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderType() == OP_SELL && OrderSymbol() == Symbol()) {
            if (!OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, clrNONE)) {
                Print("Close Sell Order Error: ", GetLastError());
            }
        }
    }
}

// Manage trailing stops
void OnTimer() {
    if (useTrailingStop) {
        for (int i = OrdersTotal() - 1; i >= 0; i--) {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
                if (OrderSymbol() != Symbol() || OrderMagicNumber() != 0) {
                    continue;
                }
                if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
                    double tradeProfit = OrderType() == OP_BUY ? (Bid - OrderOpenPrice()) : (OrderOpenPrice() - Ask);
                    tradeProfit = NormalizeDouble(tradeProfit / Point, 0);
                    if (tradeProfit > TrailingStop) {
                        double newStopLoss = OrderType() == OP_BUY ? (Bid - TrailingStop * Point) : (Ask + TrailingStop * Point);
                        if (OrderType() == OP_BUY) {
                            newStopLoss = MathMax(newStopLoss, OrderStopLoss());
                        } else {
                            newStopLoss = MathMin(newStopLoss, OrderStopLoss());
                        }
                        if (newStopLoss != OrderStopLoss()) {
                            OrderModify(OrderTicket(), OrderOpenPrice(), newStopLoss, OrderTakeProfit(), 0, 0);
                        }
                    }
                }
            }
        }
    }
}
//±-----------------------------------------------------------------+