[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exponential moving average



PureBytes Links

Trading Reference Links

At 5:52 PM -0700 9/28/00, Monte C. Smith wrote:

>Mark Jurik wrote:
>
>>The SMA has more "inertia" than the EMA. Consequently, it takes
>>longer to respond to reversals. As the cycles speed up, SMA will lag
>>further behind EMA. However, on straight trends (no cycles), the lags
>>are the same.
>
>
>Thanks Mark. The formulae for determining lag in MAs at turning points
>must look a good deal different from those that determine lags in
>'steady state' series, and the formula for making this determination in
>a SMA would then look quite a bit different from that of an EMA. If
>there is anything in print that explains it well to a non-mathematician,
>perhaps you or someone else on the List could make a recomendation?



Unfortunately, this is not a simple subject. Electrical engineers
would refer to the lag at turning points as the "transient response"
of the filter. Moving averages are really "digital filters" which are
digital versions of analog filters such as those used in the "bass
and treble controls" on your old stereo system. In the olden days,
engineers used a few electronic components to design such filters.
Now days it is much cheaper to use a million-transistor computer to
calculate the values.

There are several characteristics you have to trade off - the lag,
the overshoot, and the noise.

The lag is usually measured by how many bars the output is lagging on
a price that is moving on a sloping straight line as we have
discussed.

The overshoot is what happens when there is a sudden change in
direction. It refers to the tendency to move on beyond the price and
then catch up later. You might say this is the "lag at turning
points". The simple moving average, the exponential moving average,
and the weighted moving average have no overshoot. More sophisticated
moving averages such as the T3 average and the Jurik moving average
can have overshoot as this makes them respond faster. On the moving
averages I design for myself, I usually include a parameter for this.
As I recall the Jurik moving average has a "damping" parameter for
this purpose also. It give you more control over the tradeoff between
lag and overshoot.

A simple moving average has no overshoot at all so tends to look
pretty sluggish. It also has several annoying problems. If you apply
a 20-bar moving average to a signal that is repeating on a 20-bar
cycle, you will get NO SIGNAL. This is because the value for the new
bar added to the average is exactly equal to the value dropped off
the average at the back end. So you better not be trying to trade a
20 day cycle using a 20 day simple moving average! Engineers would
say that this digital filter has a null in its's frequency response
at the frequency corresponding to the 20-bar period.

And if the price suddenly spikes down on bar 123, the output of the
20 bar simple moving average will JUMP UP on bar 143 even if the
price is perfectly flat. This occurs because the spike value drops
off of the average suddenly at the back end. If you are using this to
signal a breakout, you might go long for no reason at all - very
disconcerting!

An exponential moving average and the weighted moving average put
more weighting on the most recent data and less and less on older
data. This makes them respond faster to changes, eliminates the
20-bar null problem, and eliminates the problem with the false
response as old data drops off of the back of the filter. As a result
of the faster response, these tend to look noisier.

The so called "end point moving average" is simply the end of a "best
least squares fit" linear regression line through all of the data
points. It has no lag at all on a sloping price line but overshoots
horribly at a turn. It also tends to be pretty noisy.

You can get rid of much of the overshoot problem of the linear
regression line by using a parabola or a cubic best-fit to the points
in what is often called a polynomial moving average. The calculations
for these were pretty time consuming until two guys figured out a
fast way to do the them so now these filters are often called
"Savizky-Golay" filters in their honor. They provide a pretty good
compromise between overshoot, noise and lag since you are fitting a
curve to the available points. The calculation are still too complex
for EasyLanguage and require a DLL, but they only have to be done on
the first bar of data so do not take much computer time.

Then there are the adaptive moving averages that adapt their
characteristics dynamically to try and optimize the tradeoffs. These
have names such as the Kaufmann AMA, Kalman filters, Tushar Chande's
VIDYA, and the Jurik AMA. Some are very useful.

As you can see, there are a lot of considerations in deciding which
to use. Each has good and bad points. Many people have spent their
complete careers figuring out ways to design such digital filters.
Since the telephone system required a lot of filters, much of the
early technology was invented at the Bell Telephone Labs and is
published in the Bell System Technical Journal. Any engineering
school library will have hundreds of books on digital filters and
digital signal processing. (Amazon.com shows 125 books on "digital
filters" and 472 books on "digital signal processing".)

Hope this helps...

Bob Fulks