sd59:
why are you trying to "reinvent the wheel"? There are many indicators on codebase that you could modify to suite your needs; using ima array and separate chart.
sd59:
You're almost there. The issue is likely due to a mismatch between the array order and how you're feeding data into it.When using iMAOnArray, make sure the array is either fully processed in reverse using ArraySetAsSeries(true) with a loop from Bars minus one to zero, or keep it in default order with ArraySetAsSeries(false) and adjust the shift index accordingly.
Right now you're mixing both, which causes the discrepancy you're seeing.
Michael Charles Schefe #: why are you trying to "reinvent the wheel"? There are many indicators on codebase that you could modify to suite your needs; using ima array and separate chart.
You're right that there are many ready-made indicators out there, and they're great for quick use. But here we're also trying to support people who want to learn how things work under the hood.
Understanding functions like iMAOnArray and how buffers behave is part of the learning curve, and sometimes that means digging deeper rather than just reusing code.
Understanding functions like iMAOnArray and how buffers behave is part of the learning curve, and sometimes that means digging deeper rather than just reusing code.
This forum isn’t just about finding shortcuts but also about helping others grow as developers.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello guys,
I have a very simple indicator drawn in a subwindow, the code of which is below:
An example of the output is shown below with an 8SMA (applied price = previous indicators data) dropped into the subwindow.
(note: there is an 8SMA also attached with is not shown in colour that uses applied price = first indicator data.)
I now want to get the values of the moving average so I use the iMAOnArray function.
The results of the print statement do not match the values of the moving average shown in the data window - so for a bar shift of 5 for example:
print statement = 533.87 data window = 544.46
I have checked many more values but the two do not agree with each other. It also doesn't seem to make much difference if I set ArraySetAsSeries to either True or False.
Can anybody see any errors please or suggest why the two values do not match?
thank you.