Download MetaTrader 5

iMAOnArray returns to me strange values

To add comments, please log in or register
Do you know that MQL5 has structures?
leo1987
43
leo1987 2015.09.09 22:19 

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
5436
Bartlomiej Gorski 2015.09.20 14:19  

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