Wrong Indicatare Value

 

Hi,

I have following code to show all RSI value of a Symbol, Every thing is doing well, But It shows wrong values for Long Distance Periods (Distance Between StartDate and EndDate is more than 10 years) Any help will appreciated.

void OnStart(){
ShowRSI(sSymbol,StartDate, EndDate);
return;
}

void ShowRSI(string sSymbol,datetime StartDate,datetime EndDate){

MqlRates  rates_array[];

ushort Decimal_Digits=0;

double RSI_Buffer[];

SetIndexBuffer(0,RSI_Buffer,INDICATOR_DATA);

ArraySetAsSeries(rates_array,true);

ushort MaxBar=TerminalInfoInteger(TERMINAL_MAXBARS);



short iCurrent=CopyRates(sSymbol,ThePeriod,StartDate,EndDate,rates_array);

if (iCurrent==-1){return;}



bars=Bars(sSymbol,ThePeriod);

if(bars>MaxBar)return;



ushort RSI_to_copy=bars;

uchar RSI_Handle=iRSI(sSymbol,ThePeriod,10,PRICE_CLOSE); 

if(RSI_Handle == INVALID_HANDLE)return ;

ushort RSI_Copy_value=CopyBuffer(RSI_Handle,0,0,RSI_to_copy,RSI_Buffer);

ArraySetAsSeries(RSI_Buffer,true);

int i;
for(i=iCurrent-1; i>=0; i--)  Alert(RSI_Buffer(i);

     return;

}
Reason: