I'm new to AFL and have some questions regarding the logic of the array/bar references. When calculating a simple moving average of length 3 and calculating the ROC of length 3. The explorer starts giving the correct values only on the 4th bar of the symbol, why is this (for SMA this is started from bar 2 and for ROC this is started from bar 1)? e.g (explorer):
I would expect the SMA and the ROC to be showing on bar 3 already (calculated from bar 1 to 3). This is because I know the close at the end of the day so I would take this price into account.
Please clarify. If my explanation is not clear, I'll try to elaborate and give more examples.
Thank you for your quick reply! I adjusted my SMA code and even made a new AFL-file with your code. The results were the same and not equal to yours. I don't understand how this is possible. The ROC code is correct now and works as expected (thank you for that one). Screenshot from my explorer in Amibroker for SMA (I took a built-in ticker now - AA):