Hi, I'm developing an indicator based on sma of a limited set of bars.
Trying different way to calculate sma I obtain different result for the same bar.
I use 4 different way to calculate the sma:
1) using SimpleMAOnBuffer on all available bars (rates_total)
2) using SimpleMA on a limited set of bar (Nbar)
3) using iMA handle over all bars available (rates_total)
4) using SimpleMAOnBuffer on a limited set of bar (Nbar)
Here the result for EURJPY,M1 on a particular bar (2016.11.15 04:31) of the three calculated SMA with period 420 :
As you can see there are differences.
My question is why?
Wouldn't be sma always the same indipendently from number of bar and the way you use to calculate it?
Which is the most reliable way to calculate a sma?
I attach the code I wrote.
Of course not.
MA is calculated over a number of bars, not one bar, so of course it matters how many bars you pull.
So not ontly the Period (timeframe) but also the MA_Period.