DownloadiMAonArray - Am I doing something wrong ?

1
Hi All,

I have been learning more MQL4 and have been trying to get the hang of arrays, which is going OK but I have noticed a problem with iMAonArray. I have scoured the internet for most of the weekend and I can't find anybody else reporting the problem so I am guessing I am doing something wrong but for my life I cannot work out what that might be.

The problem is, when I apply the iMAonArray to the whole array, it doesn't calculate it properly. I am looking for a 4 Period SMA, and when I set the iMAonArray to only cover the last four bars of the array, it calculates it correctly. However when I set the the iMAonArray to use the entire array I *think* it is caluclating the average against all bars, rather than a 4-period SMA, but either way it isn't calculating correctly. I have attached the work I have done so far.

You will notice that I have multiple loops, this was an attempt to fix the problem, as well as initializing the array and setting it as series (I have tried it in both directions),

If anybody could spare a minute to give me any tips I would be grateful.


Who is online

Users browsing this forum: No registered users and 11 guests