Can someone explain how this works please??

 

Hi

I have been learing to code and I learn much by example, I am trying to code a function to show the highest and lowest RSI for the day, here is the code:

double Rsi_high;

for(int i=0;i<Bars;i++){
    double Highest_RSI_ofDay;
    if(Time[i]>=iTime(NULL,PERIOD_D1,0)){
        if(iRSI(NULL,0,14,PRICE_CLOSE,i)>Highest_RSI_ofDay){
            Highest_RSI_ofDay=iRSI(NULL,0,14,PRICE_CLOSE,i);
    }}else{break;}


return(Highest_RSI_ofDay);}
}

double Rsi_low;

for(int i=0;i<Bars;i++){
    double Lowest_RSI_ofDay;
    if(Time[i]>=iTime(NULL,PERIOD_D1,0)){
        if(iRSI(NULL,0,14,PRICE_CLOSE,i)<Lowest_RSI_ofDay){
            Lowest_RSI_ofDay=iRSI(NULL,0,14,PRICE_CLOSE,i);
    }}else{break;}


return(Lowest_RSI_ofDay);}
}


return(0);

Is the actually returning the highest and lowest RSI of the day or have it got it wrong? :(

Thanks

Antony

 
Here this thread might help https://www.mql5.com/en/forum/128948