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.
Candle Price Action.mq4
(4.7 KiB) Downloaded 53 times


Attachments 1
  1. Similar Topics

    1. What's wrong with my code?

      2 Replies 531 Views

      by mulyanto, Sat Apr 03, 2021 1:10 am in Coding Help

      2 Replies
      531 Views
    2. iMAonArray - Coding help

      0 Replies 200 Views

      by rogerha, Fri Oct 15, 2021 2:21 am in Coding Help

      0 Replies
      200 Views
    3. Should I trade now or keep doing demo?

      21 Replies 2379 Views

      by Achille, Wed Jan 20, 2021 12:45 am in New Members & Common Forex Q&A's

      21 Replies
      2379 Views

Return to “Coding Help”

Users viewing this forum: CommonCrawl [Bot] and 3 guests