array of an indicator?

 
Hello everyone :)

I'd like to repeat the question asked by Keris2112, that is :
how to create an array of indicator values inside an experadvisor.
I'm new to mt4 and i've made only few rather simple experts. Now i'd like to employ functions like iMAOnArray but i simply don't know how to create an array which is required by iMAOnArray.
I've tried to use loops which i found in custom indicators but it didn't work, for instance:

 
double Array[] ,Ma;
int i;
for(i=0; i<Bars; i++)
Array[i]=iCCI(NULL,0,CCI_period,PRICE_TYPICAL,i);

Ma=iMAOnArray(Array,0,MaF_period,0,MODE_SMA,0);

// rest of EA



If anyone could help me out with this i'd be very grateful

Jax

 
The code looks ok to me but....

on the population of the array i think it is going the wrong way so the for statement should be

double aArray[] ,Ma;
int i;
for(i=Bars; i>=0; i--)
aArray[i]=iCCI(NULL,0,CCI_period,PRICE_TYPICAL,i);

Ma=iMAOnArray(aArray,0,MaF_period,0,MODE_SMA,0);

// rest of EA



Hope this helps you

 
Array[] should be previously resized because it has initially zero length
also You can use one of unused indicator's buffer. in this case (SetIndexBuffer(nnn,Array) You need not to resize such array. it resized automatically. for instance see our custom indicators samples(OsMA, MACD etc)
 
Many thanks for your help.
EA seems to be workig fine now :)

Jax
Reason: