iMA on Array

 

Hello,

I want to use sma that releated with previous indicator's data. Previous indicator is RSI.

I try like that:

double rsi_buffer[10];
int i,limit=ArraySize(rsi_buffer);
ArraySetAsSeries(rsi_buffer,true);

for(i=0; i<limit; i++)
rsi_buffer[i]=iRSI(NULL,0,10,PRICE_CLOSE,i);

 And sma formula is;

sma10=iMAOnArray(rsi_buffer,0,10,0,MODE_SMA,0);

But sma10 is return with "0.00000" value. 

Any idea? 

 

This code (with double sma10 declaration added):

double rsi_buffer[10];
double sma10;
int i,limit=ArraySize(rsi_buffer);
ArraySetAsSeries(rsi_buffer,true);

for(i=0; i<limit; i++)
rsi_buffer[i]=iRSI(NULL,0,10,PRICE_CLOSE,i);
sma10=iMAOnArray(rsi_buffer,0,10,0,MODE_SMA,0);

works perfectly ok. The fact that you get "0" as a result probably means, that
you don't have enough history data on a given symbol and period. Try to download
new data and check again. I can tell you for sure, that it's not a problem with code.

 
Adam Slucki:

This code (with double sma10 declaration added):

works perfectly ok. The fact that you get "0" as a result probably means, that
you don't have enough history data on a given symbol and period. Try to download
new data and check again. I can tell you for sure, that it's not a problem with code.

Hello again,

I've tried on real account, and it works perfect like you said.

 Thank you Adam :)

Reason: