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.
Marco vd Heijden:
The ma_period is the same in all the different sma calculation. So why it's not equal?
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.
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
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 :
SMA1=116.3047904761912
SMA2=116.3047904761905
SMA3=116.3047904761905
SMA4=116.3047904761901
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.