iMAonArray not working

Back to topics list To post a new topic, please log in or register
avatar
2
Metatrd 2015.10.15 13:09
 

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);
}
avatar
13009
WHRoeder 2015.10.15 18:53 #
 
Do it in OnTick when there is a chart which values.
avatar
2
Metatrd 2015.10.15 20:11 #
 
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

avatar
736
honest_knave 2015.10.15 20:25 #
 

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).
Back to topics list  

To add comments, please log in or register