If condition to function changing (To check Timeframe and Indicator)

 
I am redesigning EA, so it can have more accuracy and flexibility.

Original code :

    if(
                                  iRSI(gRandomSymbol,PERIOD_M1,RSI_Period,RSI_AppliedPrice,RSI_shift) > RSI_UpLevel &&
                                  iRSI(gRandomSymbol,PERIOD_M5,RSI_Period,RSI_AppliedPrice,RSI_shift) > RSI_UpLevel &&
                                  iRSI(gRandomSymbol,PERIOD_M15,RSI_Period,RSI_AppliedPrice,RSI_shift) > RSI_UpLevel &&
                                  iRSI(gRandomSymbol,PERIOD_M30,RSI_Period,RSI_AppliedPrice,RSI_shift) > RSI_UpLevel &&
                                  iRSI(gRandomSymbol,PERIOD_H1,RSI_Period,RSI_AppliedPrice,RSI_shift) > RSI_UpLevel &&
                                  iRSI(gRandomSymbol,PERIOD_H4,RSI_Period,RSI_AppliedPrice,RSI_shift) > RSI_UpLevel &&
    
                                  (iStochastic(gRandomSymbol,PERIOD_M1,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_MAIN,Stochastic_Shift) > Stochastic_UpLevel && iStochastic(gRandomSymbol,PERIOD_M1,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_SIGNAL,Stochastic_Shift) > Stochastic_UpLevel) &&
                                  (iStochastic(gRandomSymbol,PERIOD_M5,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_MAIN,Stochastic_Shift) > Stochastic_UpLevel && iStochastic(gRandomSymbol,PERIOD_M5,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_SIGNAL,Stochastic_Shift) > Stochastic_UpLevel) &&
                                  (iStochastic(gRandomSymbol,PERIOD_M15,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_MAIN,Stochastic_Shift) > Stochastic_UpLevel && iStochastic(gRandomSymbol,PERIOD_M15,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_SIGNAL,Stochastic_Shift) > Stochastic_UpLevel) &&
                                  (iStochastic(gRandomSymbol,PERIOD_M30,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_MAIN,Stochastic_Shift) > Stochastic_UpLevel && iStochastic(gRandomSymbol,PERIOD_M30,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_SIGNAL,Stochastic_Shift) > Stochastic_UpLevel) &&
                                  (iStochastic(gRandomSymbol,PERIOD_H1,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_MAIN,Stochastic_Shift) > Stochastic_UpLevel && iStochastic(gRandomSymbol,PERIOD_H1,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_SIGNAL,Stochastic_Shift) > Stochastic_UpLevel) &&
                                  (iStochastic(gRandomSymbol,PERIOD_H4,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_MAIN,Stochastic_Shift) > Stochastic_UpLevel && iStochastic(gRandomSymbol,PERIOD_H4,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_SIGNAL,Stochastic_Shift) > Stochastic_UpLevel) &&
    
                                  MarketInfo(gRandomSymbol, MODE_BID) > iBands(gRandomSymbol,PERIOD_M1,BollingerBands_Period,BollingerBands_deviation,BollingerBands_BandShift,BollingerBands_AppliedPrice,MODE_UPPER,BollingerBands_Shift) &&
                                  MarketInfo(gRandomSymbol, MODE_BID) > iBands(gRandomSymbol,PERIOD_M5,BollingerBands_Period,BollingerBands_deviation,BollingerBands_BandShift,BollingerBands_AppliedPrice,MODE_UPPER,BollingerBands_Shift) &&
                                  MarketInfo(gRandomSymbol, MODE_BID) > iBands(gRandomSymbol,PERIOD_M15,BollingerBands_Period,BollingerBands_deviation,BollingerBands_BandShift,BollingerBands_AppliedPrice,MODE_UPPER,BollingerBands_Shift) &&
                                  MarketInfo(gRandomSymbol, MODE_BID) > iBands(gRandomSymbol,PERIOD_M30,BollingerBands_Period,BollingerBands_deviation,BollingerBands_BandShift,BollingerBands_AppliedPrice,MODE_UPPER,BollingerBands_Shift) &&
                                  MarketInfo(gRandomSymbol, MODE_BID) > iBands(gRandomSymbol,PERIOD_H1,BollingerBands_Period,BollingerBands_deviation,BollingerBands_BandShift,BollingerBands_AppliedPrice,MODE_UPPER,BollingerBands_Shift) &&
                                  MarketInfo(gRandomSymbol, MODE_BID) > iBands(gRandomSymbol,PERIOD_H4,BollingerBands_Period,BollingerBands_deviation,BollingerBands_BandShift,BollingerBands_AppliedPrice,MODE_UPPER,BollingerBands_Shift)
                               )
                                  gSignalStatus = "RSB_UP";
    
                               if(
                                  iRSI(gRandomSymbol,PERIOD_M1,RSI_Period,RSI_AppliedPrice,RSI_shift) < RSI_BelowLevel &&
                                  iRSI(gRandomSymbol,PERIOD_M5,RSI_Period,RSI_AppliedPrice,RSI_shift) < RSI_BelowLevel &&
                                  iRSI(gRandomSymbol,PERIOD_M15,RSI_Period,RSI_AppliedPrice,RSI_shift) < RSI_BelowLevel &&
                                  iRSI(gRandomSymbol,PERIOD_M30,RSI_Period,RSI_AppliedPrice,RSI_shift) < RSI_BelowLevel &&
                                  iRSI(gRandomSymbol,PERIOD_H1,RSI_Period,RSI_AppliedPrice,RSI_shift) < RSI_BelowLevel &&
                                  iRSI(gRandomSymbol,PERIOD_H4,RSI_Period,RSI_AppliedPrice,RSI_shift) < RSI_BelowLevel &&
    
                                  (iStochastic(gRandomSymbol,PERIOD_M1,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_MAIN,Stochastic_Shift) < Stochastic_BelowLevel && iStochastic(gRandomSymbol,PERIOD_M1,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_SIGNAL,Stochastic_Shift) < Stochastic_BelowLevel) &&
                                  (iStochastic(gRandomSymbol,PERIOD_M5,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_MAIN,Stochastic_Shift) < Stochastic_BelowLevel && iStochastic(gRandomSymbol,PERIOD_M5,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_SIGNAL,Stochastic_Shift) < Stochastic_BelowLevel) &&
                                  (iStochastic(gRandomSymbol,PERIOD_M15,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_MAIN,Stochastic_Shift) < Stochastic_BelowLevel && iStochastic(gRandomSymbol,PERIOD_M15,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_SIGNAL,Stochastic_Shift) < Stochastic_BelowLevel) &&
                                  (iStochastic(gRandomSymbol,PERIOD_M30,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_MAIN,Stochastic_Shift) < Stochastic_BelowLevel && iStochastic(gRandomSymbol,PERIOD_M30,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_SIGNAL,Stochastic_Shift) < Stochastic_BelowLevel) &&
                                  (iStochastic(gRandomSymbol,PERIOD_H1,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_MAIN,Stochastic_Shift) < Stochastic_BelowLevel && iStochastic(gRandomSymbol,PERIOD_H1,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_SIGNAL,Stochastic_Shift) < Stochastic_BelowLevel) &&
                                  (iStochastic(gRandomSymbol,PERIOD_H4,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_MAIN,Stochastic_Shift) < Stochastic_BelowLevel && iStochastic(gRandomSymbol,PERIOD_H4,Stochastic_Kperiod,Stochastic_Dperiod,Stochastic_Slowing,Stochastic_Method,Stochastic_PriceField,MODE_SIGNAL,Stochastic_Shift) < Stochastic_BelowLevel) &&
    
                                  MarketInfo(gRandomSymbol, MODE_ASK) < iBands(gRandomSymbol,PERIOD_M1,BollingerBands_Period,BollingerBands_deviation,BollingerBands_BandShift,BollingerBands_AppliedPrice,MODE_LOWER,BollingerBands_Shift) &&
                                  MarketInfo(gRandomSymbol, MODE_ASK) < iBands(gRandomSymbol,PERIOD_M5,BollingerBands_Period,BollingerBands_deviation,BollingerBands_BandShift,BollingerBands_AppliedPrice,MODE_LOWER,BollingerBands_Shift) &&
                                  MarketInfo(gRandomSymbol, MODE_ASK) < iBands(gRandomSymbol,PERIOD_M15,BollingerBands_Period,BollingerBands_deviation,BollingerBands_BandShift,BollingerBands_AppliedPrice,MODE_LOWER,BollingerBands_Shift) &&
                                  MarketInfo(gRandomSymbol, MODE_ASK) < iBands(gRandomSymbol,PERIOD_M30,BollingerBands_Period,BollingerBands_deviation,BollingerBands_BandShift,BollingerBands_AppliedPrice,MODE_LOWER,BollingerBands_Shift) &&
                                  MarketInfo(gRandomSymbol, MODE_ASK) < iBands(gRandomSymbol,PERIOD_H1,BollingerBands_Period,BollingerBands_deviation,BollingerBands_BandShift,BollingerBands_AppliedPrice,MODE_LOWER,BollingerBands_Shift) &&
                                  MarketInfo(gRandomSymbol, MODE_ASK) < iBands(gRandomSymbol,PERIOD_H4,BollingerBands_Period,BollingerBands_deviation,BollingerBands_BandShift,BollingerBands_AppliedPrice,MODE_LOWER,BollingerBands_Shift)
                               )
                                  gSignalStatus = "RSB_BELOW";


This check RSI, Stochastic and BollingerBands together for all time frame but have no flexibility if i want to check for one timeframe or combination of other possibility indicator.

So, with the help of Ai, i have changed the code to

 
extern string __TradingIndicator__ = "***Trading Indicator***";
    extern bool RSI = true;
    extern bool Stochastic = true;
    extern bool BollingerBands = true;
    extern string __TimeFrame__ = "***TimeFrame Settings***";
    extern bool PeriodM1 = true;
    extern bool PeriodM5 = true;
    extern bool PeriodM15 = true;
    extern bool PeriodM30 = true;
    extern bool PeriodH1 = true;
    extern bool PeriodH4 = true;
    extern bool PeriodD1 = false;
//+------------------------------------------------------------------+
    //|  Function to check RSI conditions                                |
    //+------------------------------------------------------------------+
    void CheckRSIConditions()
      {
       gRSISignal = "NoSignal";
       bool conditionsUp[7], conditionsDown[7];
       ENUM_TIMEFRAMES periods[7];
       int count = 0;
    
       if(PeriodM1)
          periods[count++] = PERIOD_M1;
       if(PeriodM5)
          periods[count++] = PERIOD_M5;
       if(PeriodM15)
          periods[count++] = PERIOD_M15;
       if(PeriodM30)
          periods[count++] = PERIOD_M30;
       if(PeriodH1)
          periods[count++] = PERIOD_H1;
       if(PeriodH4)
          periods[count++] = PERIOD_H4;
       if(PeriodD1)
          periods[count++] = PERIOD_D1;
    
       if(count == 0)
          return;  // Exit if no timeframes are selected
    
       bool allTrueUp = true, allTrueDown = true;
    
       for(int i = 0; i < count; i++)
         {
          double rsiValue = iRSI(gRandomSymbol, periods[i], RSI_Period, RSI_AppliedPrice, RSI_shift);
          conditionsUp[i] = (rsiValue > RSI_UpLevel);
          conditionsDown[i] = (rsiValue < RSI_BelowLevel);
    
          allTrueUp   &= conditionsUp[i];   // If any is false, allTrueUp becomes false
          allTrueDown &= conditionsDown[i]; // If any is false, allTrueDown becomes false
         }
    
       if(allTrueUp)
          gRSISignal = "UP";
       if(allTrueDown)
          gRSISignal = "BELOW";
      }
    
    //+------------------------------------------------------------------+
    //| Function to check Stochastic conditions                          |
    //+------------------------------------------------------------------+
    void CheckStochasticConditions()
      {
       gStochasticSignal = "NoSignal";
       bool conditionsUp[7], conditionsDown[7];
       ENUM_TIMEFRAMES periods[7];
       int count = 0;
    
       if(PeriodM1)
          periods[count++] = PERIOD_M1;
       if(PeriodM5)
          periods[count++] = PERIOD_M5;
       if(PeriodM15)
          periods[count++] = PERIOD_M15;
       if(PeriodM30)
          periods[count++] = PERIOD_M30;
       if(PeriodH1)
          periods[count++] = PERIOD_H1;
       if(PeriodH4)
          periods[count++] = PERIOD_H4;
       if(PeriodD1)
          periods[count++] = PERIOD_D1;
    
       if(count == 0)
          return;  // Exit if no timeframes are selected
    
       bool allTrueUp = true, allTrueDown = true;
    
       for(int i = 0; i < count; i++)
         {
          double mainValue   = iStochastic(gRandomSymbol, periods[i], Stochastic_Kperiod, Stochastic_Dperiod, Stochastic_Slowing, Stochastic_Method, Stochastic_PriceField, MODE_MAIN, Stochastic_Shift);
          double signalValue = iStochastic(gRandomSymbol, periods[i], Stochastic_Kperiod, Stochastic_Dperiod, Stochastic_Slowing, Stochastic_Method, Stochastic_PriceField, MODE_SIGNAL, Stochastic_Shift);
    
          conditionsUp[i]   = (mainValue > Stochastic_UpLevel && signalValue > Stochastic_UpLevel);
          conditionsDown[i] = (mainValue < Stochastic_BelowLevel && signalValue < Stochastic_BelowLevel);
    
          allTrueUp   &= conditionsUp[i];   // If any condition is false, allTrueUp becomes false
          allTrueDown &= conditionsDown[i]; // If any condition is false, allTrueDown becomes false
         }
    
       if(allTrueUp)
          gStochasticSignal = "UP";
       if(allTrueDown)
          gStochasticSignal = "BELOW";
      }
    
    //+------------------------------------------------------------------+
    //|   Function to check Bollinger Band conditions                    |
    //+------------------------------------------------------------------+
    void CheckBollingerBandsConditions()
      {
       gBollingerBandsSignal = "NoSignal";
       bool conditionsUp[7], conditionsDown[7];
       ENUM_TIMEFRAMES periods[7];
       int count = 0;
    
       if(PeriodM1)
          periods[count++] = PERIOD_M1;
       if(PeriodM5)
          periods[count++] = PERIOD_M5;
       if(PeriodM15)
          periods[count++] = PERIOD_M15;
       if(PeriodM30)
          periods[count++] = PERIOD_M30;
       if(PeriodH1)
          periods[count++] = PERIOD_H1;
       if(PeriodH4)
          periods[count++] = PERIOD_H4;
       if(PeriodD1)
          periods[count++] = PERIOD_D1;
    
       if(count == 0)
          return;  // Exit if no timeframes are selected
    
       bool allTrueUp = true, allTrueDown = true;
       double bidPrice = MarketInfo(gRandomSymbol, MODE_BID);
       double askPrice = MarketInfo(gRandomSymbol, MODE_ASK);
    
       for(int i = 0; i < count; i++)
         {
          double upperBand = iBands(gRandomSymbol, periods[i], BollingerBands_Period, BollingerBands_deviation, BollingerBands_BandShift, BollingerBands_AppliedPrice, MODE_UPPER, BollingerBands_Shift);
          double lowerBand = iBands(gRandomSymbol, periods[i], BollingerBands_Period, BollingerBands_deviation, BollingerBands_BandShift, BollingerBands_AppliedPrice, MODE_LOWER, BollingerBands_Shift);
    
          conditionsUp[i]   = (bidPrice > upperBand);
          conditionsDown[i] = (askPrice < lowerBand);
    
          allTrueUp   &= conditionsUp[i];   // If any condition is false, allTrueUp becomes false
          allTrueDown &= conditionsDown[i]; // If any condition is false, allTrueDown becomes false
         }
    
       if(allTrueUp)
          gBollingerBandsSignal = "UP";
       if(allTrueDown)
          gBollingerBandsSignal = "BELOW";
      }
    
    //+------------------------------------------------------------------+
    //|    Indicator Possibilities                                       |
    //+------------------------------------------------------------------+
    void MultiTF_IndicatorPossibilities()
      {
       gMultiTimeFrameSignalStatus = "NoSignal";
       string signals[3]; // Max size for RSI, Stochastic, and BollingerBands
       int count = 0;
    
       if(RSI)
          signals[count++] = gRSISignal;
       if(Stochastic)
          signals[count++] = gStochasticSignal;
       if(BollingerBands)
          signals[count++] = gBollingerBandsSignal;
    
    // Early exit if no indicators are enabled
       if(count == 0)
          return;
    
       bool allUP = true, allBELOW = true;
    
       for(int i = 0; i < count; i++)
         {
          if(signals[i] != "UP")
             allUP = false;
          if(signals[i] != "BELOW")
             allBELOW = false;
         }
    
       if(allUP)
          gMultiTimeFrameSignalStatus = "UP";
       if(allBELOW)
          gMultiTimeFrameSignalStatus = "BELOW";
      } 
  


I have also tried my best to debug and make the code working. i guess something missing which i am unable to find out. I request you to please review and let me know what changes should i make to make my code working.