Adding time controls to RSI hi_Lo function

 

Hi

I have this RSI that calculates highest and lowest RSI values of the day:

int NewPeackRsi(string buy_sell,int bar=0){
        int i,x,y,t,pt;
        static double prewHi,prewLo;    
        for(i=3;i>0;i--){if(TimeCurrent()<StrToTime(time[i])){t=StrToTime(time[i-1]);}}
        if(t==0){t=StrToTime(time[3]);}
        int pbar = iBarShift(Symbol(),Period(),t,false);
        if(pbar<bar){pbar=bar+20;}
        double prewRsiHi = 0,prewRsiLo = 100;
        
          int theRsiPeriod;
   if(Period() == PERIOD_M1)
      theRsiPeriod = RsiPeriod2;
   else
      theRsiPeriod = RsiPeriod;
      
        for(i = pbar; i > bar; i--){
           double rsi = iRSI(Symbol(),Period(),theRsiPeriod,0,i);
                if(prewRsiHi < rsi){prewRsiHi = rsi;}
                if(prewRsiLo > rsi){prewRsiLo = rsi;}
        }
        //Print(pbar,"  ",bar,"  ",prewRsiHi,"  ",prewRsiLo,"  ",rsi);
        rsi = iRSI(Symbol(),Period(),theRsiPeriod,0,bar);
   if(buy_sell == "BUY"){// if new RSI peack
                if(rsi >= prewRsiHi+1){
                //Print("Current ",rsi," > ",prewRsiHi,"Prevous Hi");
                        prewRsiHi = rsi;
                        return(1);
                }
   }
   if(buy_sell == "SELL"){// if newRSI peack down
                if(rsi <= prewRsiLo-1){
                //Print("Current ",rsi," < ",prewRsiLo,"Prevous LOw");
                        prewRsiLo = rsi;
                        return(1);
                }       
   }
   return(0);
}

What I need to do is set it up so that after 0800 the function looks for the highest and lowest values between 0000 and the current time. The after 1300 the function looks for the high low values fom 0500 to the current time.

I am new to coding but a few pointers will be very helpful.

Thanks

Antony