Difference Between Exponential and Simple Moving Averages

 Roundtable Fellow
 Posts: 50
 Joined: Fri Apr 18, 2003 8:53 pm
 Location: Huntsville, AL
 Contact:
Difference Between Exponential and Simple Moving Averages
I use average true range to measure volatility for setting stops, position sizing, etc. I use both Trading Recipes and Tradestation, and have learned from doing comparison tests that the two programs calculate ATR differently. TR calculates ATR as an exponential moving average (the same way Welles Wilder calculated it in his book), while Tradestation calculates it as a simple moving average. I have found that the different methods produce different results. The ATR calculation in TR uses a smoothing factor equal to 1/n, where n is the length of the exponential moving average. I have also found that the more traditional exponential moving average, which uses a smoothing factor equal to 2/n, provides better results, at least for the one set of tests that I performed. The test is for a system I trade. For 15 markets, tested from 19842005, assuming $75 in slippage and commission per trade, using a simple moving average to calculate ATR yielded an average per trade profit equal to $675. Using the Wilder ATR formula also yielded an average profit equal to $675, even though the amounts varied somewhat from one market to another. But using the smoothing factor equal to 2/n (the traditional exponential moving average) yielded much better profits  $731 per trade (see attached file for details). I found this to be an interesting result, as even seemingly trivial differences can make a noticeable difference in overall results. How does Trading Blox calculate ATR, and does the user have control over how to calculate ATR?
 Attachments

 MA comparison.xls
 (15.5 KiB) Downloaded 474 times
TBB has chosen a selfconsistent definition of ATR and calculates it correctly (in my opinion). You will enjoy figuring out what definition it employs, by looking at some TBB output and seeing which of YOUR definitions, compute the same answers as TBB.
Attached is a price history in Excel format, with TBB's calculated value of the 10 (ten) day ATR. This is chopped out of the middle of a test run, long long LONG after the priming has completed and convergence to seven decimal places has occurred.
Try a few possible definitions of "10 day ATR" and see which one matches the TBB output. Won't take you long.
Attached is a price history in Excel format, with TBB's calculated value of the 10 (ten) day ATR. This is chopped out of the middle of a test run, long long LONG after the priming has completed and convergence to seven decimal places has occurred.
Try a few possible definitions of "10 day ATR" and see which one matches the TBB output. Won't take you long.
 Attachments

 atr.zip
 atr values
 (16.12 KiB) Downloaded 378 times

 Roundtable Fellow
 Posts: 60
 Joined: Sat Feb 07, 2004 10:34 am
 Location: Washington DC
Re: Difference Between Exponential and Simple Moving Average
Oh come on. This is only a problem because people are too lazy to talk about exponential moving averages in terms of the smoothing constant (alpha). Instead, everybody feels more comfortable talking about "the number of days" in an "equivalent" simple moving average.Christian Smart wrote:I have also found that the more traditional exponential moving average, which uses a smoothing factor equal to 2/n, provides better results
Even when someone is scrupulously careful to only talk about smoothing constants, the great mass of The People translate it into the more comfortable "number of days". Gerald Appel invented the MACD indicator, which used exponential smoothing constants 0.15, 0.075, and 0.20. He explicitly defined MACD in terms of these smoothing constants. Immediately The People "converted" this into 12,26,9 because integer number of days are more comfortable. (Fun project: the people made a calculation error when they converted MACD   see if you can spot it.)
If you want ideal portable perfection in your system code, don't use "number of days" (and don't use built in functions). Instead use exponential smoothing constants and code up the smoother yourself.
Three popular trading packages have chosed three different formulae for converting between exponential smoothing constant (alpha) and "number of days" (N). Therefore you will get different answers if you compute ATR on each of them. One way to sidestep this problem, permanently, is mentioned in the previous paragraph.
 Attachments

 atr.png (11.78 KiB) Viewed 6785 times
Hi Christian,
the long answer: you can find it at p. 108 of the Trading_Blox UserGuide.pdf, freely downloadable in the "support area".
The short answer (from p. 108):
" Trading Blox allows you to set the number of days to use when creating an Average True Range Indicator, and we use the Exponential Moving Average to calculate this indicator.
This is a different formula than the Wilder Moving Average Formula. As an example, the 20 day Wilder ATR is the equivalent to a 39 day Exponential ATR.
Exponential MA Days = (Wilder MA Days X 2)  1 ".
the long answer: you can find it at p. 108 of the Trading_Blox UserGuide.pdf, freely downloadable in the "support area".
The short answer (from p. 108):
" Trading Blox allows you to set the number of days to use when creating an Average True Range Indicator, and we use the Exponential Moving Average to calculate this indicator.
This is a different formula than the Wilder Moving Average Formula. As an example, the 20 day Wilder ATR is the equivalent to a 39 day Exponential ATR.
Exponential MA Days = (Wilder MA Days X 2)  1 ".

 Roundtable Fellow
 Posts: 50
 Joined: Fri Apr 18, 2003 8:53 pm
 Location: Huntsville, AL
 Contact:
Thanks to everyone for their answers.
In my opinion, it seems reasonable to relate the smoothing factor to the length. With a simple moving average, the length is a necessary ingredient, and exponential moving averages are typically expressed in terms of length, 10day, 50day, 100day, etc., so I think it makes sense to express them in terms of length. With an nday exponential moving average, if the smoothing factor is 1/n, then you're weighting the latest value the same as the remaining (n1)/n%. If it's 2/n, you're giving the latest value twice the weight. I've done some testing with writing my own EMA functions, and using 2/(n+1), as Trading Blox Builder seems to do, works better than other values, at least for some purposes.
In my opinion, it seems reasonable to relate the smoothing factor to the length. With a simple moving average, the length is a necessary ingredient, and exponential moving averages are typically expressed in terms of length, 10day, 50day, 100day, etc., so I think it makes sense to express them in terms of length. With an nday exponential moving average, if the smoothing factor is 1/n, then you're weighting the latest value the same as the remaining (n1)/n%. If it's 2/n, you're giving the latest value twice the weight. I've done some testing with writing my own EMA functions, and using 2/(n+1), as Trading Blox Builder seems to do, works better than other values, at least for some purposes.

 Roundtable Fellow
 Posts: 50
 Joined: Fri Apr 18, 2003 8:53 pm
 Location: Huntsville, AL
 Contact:
Here's an equity curve comparison for one system, with ATR measured as 1. a simple moving average (SMA); 2. an exponential moving average with smoothing factor 1/n (Wilder's EMA), and 3. the traditional 2/n smoothing factor (Traditional EMA). Wilder's EMA and the simple moving average provide similar results, but both are handily beaten by the EMA that weights recent experience more heavily. This makes intuitve sense to me  the most recent day should have a bigger weight than the previous periods.
 Attachments

 MA Comparison.jpg (42.46 KiB) Viewed 6688 times

 Contributor
 Posts: 1
 Joined: Thu Dec 18, 2008 12:10 pm
which smoothing factor does trading blox use?
Tradingblox uses 2/(n+1) as alpha (smoothing factor)? Please look at this site http://en.wikipedia.org/wiki/Moving_average.