iMAonArray not working

 

I'm trying to call this function with an array of RSI values to find the EMA but it's not working properly, always return 0.0 no matter which shift I choose. I can ensure the array gets properly filled with correct RSI values

It works fine if I make the same exact thing with closing prices

Any help appreciated, thanks in advance

int OnInit()
{
   double RSI_values[];
   ArrayResize(RSI_values, Bars, 0);
   ArraySetAsSeries(RSI_values, true);
   for(int i=0; i < Bars; i++)
   {
       RSI_values[i] = iRSI(Symbol(), NULL, RSI_period, RSI_applied_price, i);
   }

   double EMA = iMAOnArray(RSI_values, 0, 17, 0, MODE_EMA, 0);
   Alert(EMA);
}
 
Do it in OnTick when there is a chart which values.
 
WHRoeder:
Do it in OnTick when there is a chart which values.

It seems to work and I can't thank you enough, could you please explain why?

I can't figure out how this is possible

 

From here

It is not recommended to call start() from init() or to perform trade operations from init(), because during initialization values of information environment parameters may be not ready (information about charts, market prices and so on).
Reason: