newbie needs help in Accelerator indicator -> Array

 

Hello,

I am trying to use the existing Accelerator indicator and put it in array but my array doesn't seem to give me the correct figure. Can someone point out the mistake?

The Original Accelerator indicator below.

//+------------------------------------------------------------------+
//| Accelerator/Decelerator Oscillator |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
double prev,current;
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd counted in the 1-st additional buffer
for(int i=0; i<limit; i++)
ExtBuffer3[i]=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,i);
//---- signal line counted in the 2-nd additional buffer
for(i=0; i<limit; i++)
ExtBuffer4[i]=iMAOnArray(ExtBuffer3,Bars,5,0,MODE_SMA,i);
//---- dispatch values between 2 buffers
bool up=true;
for(i=limit-1; i>=0; i--)
{
current=ExtBuffer3[i]-ExtBuffer4[i];
prev=ExtBuffer3[i+1]-ExtBuffer4[i+1];
if(current>prev) up=true;
if(current<prev) up=false;
if(!up)
{
ExtBuffer2[i]=current;
ExtBuffer1[i]=0.0;
}
else
{
ExtBuffer1[i]=current;
ExtBuffer2[i]=0.0;
}
ExtBuffer0[i]=current;
}
//---- done
return(0);
}

//+------------------------------------------------------------------+

I tried to change it to array below. Changes in red line only.

void AC()

{

int limit

int counted_bars=IndicatorCounted();

double prev,current;

//---- last counted bar will be recounted

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

double array_AC_0[50], array_AC_1[50], array_AC_2[50], array_AC_3[50], array_AC_4[50]; // initialize array of 50 ok?

//---- macd counted in the 1-st additional buffer

for(int i=0; i<limit; i++)

array_AC_3[i]=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,i);

//---- signal line counted in the 2-nd additional buffer

for(i=0; i<limit; i++)

array_AC_4[i]=iMAOnArray(array_AC_3,Bars,5,0,MODE_SMA,i);

//---- dispatch values between 2 buffers

bool up=true;

for(i=limit-1; i>=0; i--)

{

current=array_AC_3[i]-array_AC_4[i];

prev=array_AC_3[i+1]-array_AC_4[i+1];

if(current>prev) up=true;

if(current<prev) up=false;

if(!up)

{

array_AC_2[i]=current;

array_AC_1[i]=0.0;

}

else

{

array_AC_1[i]=current;

array_AC_2[i]=0.0;

}

array_AC_0[i]=current;

}

return (0);

}

The array_AC_0[0] does not return the current Accelerator figure.


 
Your code doesn't have tabs & formatting. Please put your code with the SRC button. Cut it in two posts if it's too long.