OPEN-SOURCE SCRIPT

META: STDEV Study (Scripting Exercise)

3772
While trying to figure out how to make the STDEV function use an exponential moving average instead of simple moving average , I discovered the builtin function doesn't really use either.

Check it out, it's amazing how different the two-pass algorithm is from the builtin!

Eventually I reverse-engineered and discovered that STDEV uses the Naiive algorithm and doesn't apply "Bessel's Correction". K can be 0, it doesn't seem to change the data although having it included should make it a little more precise.

en.wikipedia.org/wiki/Algorithms_for_calculating_variance

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.