# R. I. P. EMA

**The Average Investor's Blog » R**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

That’s right, I am moving away from exponential moving averages. Originally, I decided to use them somewhat arbitrary, probably because they tend to swing faster. Last night, after spending two and half hours debugging an issue which yet again turned out to be a particular property of these averages, I made my mind. I am back to simple moving averages and probably weighted moving averages for faster convergence.

What is the annoying property of exponential moving averages? They are recursive. In other words, each consecutive value is computed using the previous value. So what’s the problem? Here is an illustration:

library( quantmod ) getSymbols( "SPY", from="1900-01-01" ) spyEMA = EMA( tail( Cl( SPY ), 300 ), 200 ) print( as.numeric( last( spyEMA ) ) ) spyEMA = EMA( tail( Cl( SPY ), 400 ), 200 ) print( as.numeric( last( spyEMA ) ) )

Guess what the output is? That’s right – it’s different!

[1] 123.0065 [1] 123.4964

Not quite beneficial for trading research and since it has manifested on multiple occasions, it’s certainly time to move on.

**leave a comment**for the author, please follow the link and comment on their blog:

**The Average Investor's Blog » R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.