Download MetaTrader 5

iMAOnArray returns to me strange values

To add comments, please log in or register
leo1987
43
leo1987  

Hi,

I am trying to build an indicator and I need an MA on a Buffer I am calculating. For this reason I used the iMAOnArray function. Buffer's field of existence is [0;1]  and it also usually never comes above .5. 

When trying to get this MA set as:

double temp = 0.0;
temp = iMAOnArray(ExtUpProb /*(one of indicators buffer)*/, 200 /*(I want to take in account only the last 200 buffer elements)*/, 14 /*(MA Period)*/, 0,1,0);

but it returns to me 0 or BILLIONS in value! (at most a constant value sometimes).

I have declared the container variable, I have initialized it but result is always the same. How could I configure it?

In the indicator's for loop it should be:

for (int i = Bars-1; i>=0; i--)
{
//...
ExtUpProb[i] = // stuff
iMAOnArray(ExtUpProb,200,14,0,1,0); or iMAOnArray(ExtUpProb,200,14,0,1,i); with "i" shift to let it dynamic? }

 

Thank you very much! 

Bartlomiej Gorski
5501
Bartlomiej Gorski  

Hi,

Hard to say without full code, maybe your indicator is returing you this value : 214783647  (EMPTY_VALUE)?

Try to do this:

1) fill indicator buffer first

2) calculate iMaOnArray in second loop

int i;
for (i = Bars-1; i>=0; i--)
{
   ExtUpProb[i] = // stuff
}
for (i = Bars-1; i>=0; i--)
{
   myMaCalculationsBuffer[i] = iMAOnArray(ExtUpProb,200,14,0,1,i);
}
 


And also allways use "i" when calling iMaOnArray as last parameter, otherwise you will fill your buffer with just last value that comes from calculations.

To add comments, please log in or register