Download MetaTrader 5

iMA on Array

To add comments, please log in or register
Have you developed a trading robot? Publish it in the Market and make profit!
ilkeru
39
ilkeru 2015.10.25 14:09 

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? 

Adam Slucki
412
Adam Slucki 2015.10.26 11:14  

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.

ilkeru
39
ilkeru 2015.10.26 13:01  
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 :)

To add comments, please log in or register