Page 1 of 1

Difference Between Exponential and Simple Moving Averages

Posted: Tue Mar 07, 2006 11:10 pm
by Christian Smart
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 1984-2005, 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?

Posted: Wed Mar 08, 2006 8:41 am
by sluggo
TBB has chosen a self-consistent 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.

Re: Difference Between Exponential and Simple Moving Average

Posted: Wed Mar 08, 2006 9:54 am
by stancramer
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
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.

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.

Posted: Wed Mar 08, 2006 12:29 pm
by Turtle40
The answer, quick one that is, can be found on p14.1 of the pdf guide.
(Glossary of Terms)

Posted: Wed Mar 08, 2006 3:57 pm
by Angelo
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 ".

Posted: Wed Mar 08, 2006 11:53 pm
by Christian Smart
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, 10-day, 50-day, 100-day, etc., so I think it makes sense to express them in terms of length. With an n-day exponential moving average, if the smoothing factor is 1/n, then you're weighting the latest value the same as the remaining (n-1)/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.

Posted: Thu Mar 09, 2006 12:33 am
by Christian Smart
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.

which smoothing factor does trading blox use?

Posted: Wed Mar 18, 2009 4:09 pm
by trending617
Tradingblox uses 2/(n+1) as alpha (smoothing factor)? Please look at this site http://en.wikipedia.org/wiki/Moving_average.