• Join us

Confused with iMAOnArray

To add comments, please log in or register
monyet
7
monyet  
I hope somebody can comment on this.

Here's the start()
int iL1, iLimit;
int counted_bars=IndicatorCounted();
if (counted_bars<0) return(-1);
if (counted_bars>0) counted_bars--;
iLimit=Bars - counted_bars;
Alert("iLimit = " + iLimit + " Bars = " + Bars + " counted_bars = " + counted_bars + " Array size = " + ArraySize(MB3));
for(iL1=0; iL1<iLimit; iL1++)
{
MB4[iL1] = (High[iL1]+Low[iL1]+Close[iL1])/3;
Alert("HLC/3 " + iL1 + " " + MB4[iL1]);
MB3[iL1] = iMAOnArray(MB4, 0, 4, 0, MODE_EMA, 0);
Alert("iMAOnArray(4) " + MB3[iL1]);
}
return(0);

What I would like to do is this :
First gather all the HLC/3 with MB4 array, then calculate it's EMA ( 4 bar ) with MB3.
When the program start, it shows :
iLimit = 27329 Bars = 27329 counted_bars=0 Array size = 27329
Ok, now after that a series of HLC/3 appears, from 0 to 27328.
HLC/3 [0] = 1.19143333
HLC/3 [1] = 1.1930000
HLC/3 [2] = bla bla bla
until HLC3 [10].
But the iMAOnArray (4) displays 1288490188.67657330 even after thousands of correct HLC/3 value.
I though that if I have at least 4 HLC/3 data on MB4 array, iMAOnArray should have been able to calculate the correct value.
May be I use the wrong iMAOnArray parameter ?

Please help.
Thank you in advanced
Slava
Moderator
13395
Slava  
Set "Empty Value" for your indicator buffers to 0
monyet
7
monyet  
I hope I got it right.
I think it is because of uninitialize values of the array.

Thank you for your support :)
Best regards
To add comments, please log in or register