Getting Back to Basics:
Ever wondered, "Why should we bother with the simple moving average (SMA) when it's already out there?"
Well, there are a few solid reasons:
- Many existing SMA calculations face one of two common issues (or sometimes both):
- When you extend the calculation period, they tend to slow down due to repeated loops.
- If they skip loops, they might use a shortcut that approximates the SMA, which can be frustrating when you’re looking for precision.
- They can be a bit tricky to use.
So, here’s a version that avoids approximations, doesn’t slow down with longer periods, and is easy to implement (even in code!).
Just a heads up: you could optimize it further by migrating the code from the class to the main loop, but that might sacrifice some flexibility for a marginal speed boost.



Comments 0