Programming an EA with an indicator which uses "Previous Indicator's Data"

 

Hi,

I have programmed the following code:

double MA_Buffer[300];
double RSI_on_MA[300];

void CalcRSI()
{
int    i,limit=ArraySize(MA_Buffer);
ArraySetAsSeries(MA_Buffer,true);
for(i=0; i<limit; i++)
   MA_Buffer[i]=iMA(NULL,0,13,8,MODE_SMMA,PRICE_MEDIAN,i);
   
for(i=0; i<limit; i++)
 {
   RSI_on_MA[i]=iRSIOnArray(MA_Buffer,limit,RSI_Period,i-1);
   Print("RSI_on_MACD = ", RSI_on_MA[i]);
 } 
}


But the value of the RSI_on_MA[] is always 0. Can you see why??
 
sunshineh:

Can you see why??

Despite what I said in another post . . I'm not actually Psysic . . . you don't tell use what MACD_FastEMA, MACD_SlowEMA, MACD_SignalPeriod, MODE_SIGNAL or RSI_Period are set to.

Is the MACD_Buffer correct ? have you checked it's values by adding a Print statement ?

 

Thank you for your answer!

I have checkt the MACD_Buffer and it is correct, with the right values (so my MACD-Variables are right)

extern int RSI_Period = 20;


Is it right to write "i-1" because I want the indicator which uses "Previous Indicator's Data"? In the RSI_on_MACD-Buffer is always 0.

RSI_on_MACD[i]=iRSIOnArray(MACD_Buffer,limit,RSI_Period,i-1);
 
All I know about iRSIOnArry is what I have read in the documentation . . I'm not into Technical Indicators at all . . but it seems to me that limit should be > RSI_Period
 
  1. for(i=0; i<limit; i++)
       MACD_Buffer[i]=iMACD(NULL,0, MACD_FastEMA, MACD_SlowEMA, MACD_SignalPeriod, PRICE_CLOSE, MODE_SIGNAL, 1);
    all elements are set to the same value?
  2. for(i=0; i<limit; i++){
       RSI_on_MACD[i]=iRSIOnArray(MACD_Buffer,limit,RSI_Period,i-1);
    There is no element i-1 when i==0
 
Thank you very, very much!!!!
Reason: