The Average Investor's Blog

A software developer view on the markets

R. I. P. EMA

Posted by The Average Investor on Oct 20, 2011

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.


One Response to “R. I. P. EMA”

  1. eran said

    I think it is importnat to keep heavier weights closer to present. You can easily write something like that for yourself. Its well worth it if you are using it often. I am planning to do so myslef in the weeks to come. Will share it if I think its useable.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: