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.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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.
//+------------------------------------------------------------------+//+------------------------------------------------------------------+
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.