problem indicators: using past values

 
Hello.

I would like to know how to make an indicator that takes past bar values. I have this code in the special function star:

Buf_0 [i] = IMA (NULL, 0,13,0, MODE_SMMA, PRICE_MEDIAN, i)-IMA (NULL, 0,24,0, MODE_SMMA, PRICE_MEDIAN, i);

If in one of the indicators, I want to select values of 3 graphics ago, I change "i" with "3. " But it says error.

I guess I have to change the "i" in Buf_0 [i]; but I don't know how to write correctly.

Let say I want the indicador make this: IMA (NULL, 0,13,0, MODE_SMMA, PRICE_MEDIAN, 3)-IMA (NULL, 0,24,0, MODE_SMMA, PRICE_MEDIAN, 3)

Values refers to 3 bars back (and nt to "i").



Can someone help me with this?


Thanks

trader201


Here is the complete code, just in case:

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red

double Buf_0[];

int init()
{
SetIndexBuffer(0,Buf_0);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);

return(0);
}

int deinit()
{
return(0);
}

int start()
{
int i, counted_bars;
counted_bars=IndicatorCounted();
i=Bars-counted_bars-1;

while (i>0)
{
Buf_0[i]=iMA(NULL,0,13,0,MODE_SMMA,PRICE_MEDIAN,i)-iMA(NULL,0,24,0,MODE_SMMA,PRICE_MEDIAN,i);
i--;
}
return(0);
}

 
use i+3
Reason: