Optimal Tracking Filters Ehlers
Optimal Tracking Filters Ehlers
By
John Ehlers
INTRODUCTION
Dr. R.E. Kalman introduced his concept of optimum estimation in 1960. Since
that time, his technique has proven to be a powerful and practical tool. The approach is
particularly well suited for optimizing the performance of modern terrestrial and space
navigation systems. Many traders not directly involved in system analysis have heard
about Kalman filtering and have expressed an interest in learning more about it for
market applications. Although attempts have been made to provide simple, intuitive
explanations, none has been completely successful. Almost without exception,
descriptions have become mired in the jargon and state-space notation of the “cult”.
Surprisingly, in spite of the obscure-looking mathematics (the most impenetrable
of which can be found in Dr. Kalman’s original paper), Kalman filtering is a fairly direct
and simple concept. In the spirit of being pragmatic, we will not deal with the full-blown
matrix equations in this description and we will be less than rigorous in the application to
trading. Rigorous application requires knowledge of the probability distributions of the
statistics. Nonetheless we end with practically useful results. We will depart from the
classical approach by working backwards from Exponential Moving Averages. In this
process, we introduce a way to create a nearly zero lag moving average. From there,
we will use the concept of a Tracking Index that optimizes the filter tracking for the given
uncertainty in price movement and the uncertainty in our ability to measure it.
SUB-OPTIMAL FILTERS
Tracking filters are used to estimate the position of a target using a linear model.
Equation 1, called an Alpha filter, shows that this model is comprised of using the
previous estimate plus a constant times the difference between the last real position
and the last estimate.
But this is exactly the same thing as the Exponential Moving Average (EMA) with which
you are familiar. I prefer to rearrange the terms so that the EMA is written as:
As you know, this equation for the EMA produces a lag in the estimated price. We can
improve our estimate of position by adding an estimate of the velocity to the last known
position in Equation 1. Equation 1 then becomes:
In general, the velocity estimate is an EMA of the rate of change of position, so that:
I took the liberty of using the four day “Momentum” (a misnomer if ever there was one)
as the velocity estimate. Figure 1 shows the EMA using = 0.25 compared to the
ZEMA using the same alpha and K = 0.5. This is not a bad “zero lag” filter, even if it is
sub-optimal.
MATHEMATICAL MODEL
Now that you are a little familiar with the model of target motion, the more
general linear ideal model is
6) y = y[1] + w[1]
where y[1] is the target state vector at time [1], is the state transition matrix, w[1] is the
unknown target maneuver, and is the maneuver/state transition matrix. The
performance of the estimation process is determined by the statistical characteristic of
the estimation process. Since this system is linear and the noise processes are
assumed to be white, the optimal mean-squared-error is the Kalman filter. There are
errors in both the uncertainty of the maneuver and the uncertainty in the position
measurement. Kalata1 has introduced the concept of a Tracking Index, . He defines
the Tracking Index as:
We will return to the interpretation of the Tracking Index to price charts, but for now we
will complete our mathematical model. Given that is given, it implicitly specifies the
optimal steady state solution. Grinding through the math, the solution for the alpha
filter is:
8)
2 (4 162 )
8
1
Paul R. Kalata, “The Tracking Index: A Generalized Parameter for and Target Trackers”,
IEEE Transactions on Aerospace and Electronic Systems”, Vol AES-20, No.2, March 1984, p 174-182
We use the same alpha for an alpha-beta filter, and additionally have the relationship:
9)
2(2 ) 4 (1 )
inputs:Price((h+l)/2);
vars: lambda(0),
alpha(0);
Plot1(Value3, "AlphaTrack");
2
John Ehlers, “Signal Analysis Concepts”
relatively smooth when the price has a sideways action. The operation of this filter is
similar to Kaufman’s Adaptive Moving Average 3. In this case, you know the filter is
optimal for the given uncertainty in the price movement and the measurement of that
movement. Notice how the tracking filter flattens in sideways market conditions. I
conclude that this optimum tracking filter can lead to far fewer whipsaw signals. The
simple Alpha Optimum Tracking Filter can be easily extended to an Optimum Alpha-
Beta filter that has even tighter tracking. Which is better for trading? That’s where you
come in. It is your project to imbed these optimum filters in your own indicators and
trading systems.
3
Perry J. Kaufman, “Smarter Trading”, McGraw-Hill, 1995
Figure 1. EMA ( = .25) and Zero Lag Moving Average