- All you've done is implement what every optimized SMA already does: SMA(i) = SMA(i-1) + (Close[i] - Close[i+period])/period.
- But only for SMA(close)
- Wrong for the first period values! I.e. for the second value you compute (Close[0] * (period-1) + Close[1] ) / period which is not the SMA of two values.
- And you did it with two buffers instead of one.
All you've done is implement what every optimized SMA already does.
(1) Okay, although I don't see the exact same implementation on code base. Do point me if it has already been done here. Thanks :)
(2) It is an example, any potential coder can add price options.
(3) It's (i==period)
(4) Would like to see how that is done
(1) Okay, although I don't see the exact same implementation on code base. Do point me if it has already been done here. Thanks :)
(2) It is an example, any potential coder can add price options.
(3) It's (i==period)
(4) Would like to see how that is done
just for point 1 : https://www.mql5.com/en/code/24984
PS: you should revise your initial sum (it shall carry wrong sum to later bars)

just for point 1 : https://www.mql5.com/en/code/24984
PS: you should revise your initial sum (it shall carry wrong sum to later bars)
You work is great. But the point of my implementation was to eliminate loop. How would my initial calculation cause wrong future values?
You should check the code you are referenced to before commenting
As of the sum (and inheriting the wrong sum) : please do your math
all the best
You should check the code you are referenced to before commenting
As of the sum (and inheriting the wrong sum) : please do your math
all the best

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
SMA(no loop):
Fast way calculate Simple moving average.
Author: Navdeep Singh