0% found this document useful (0 votes)
297 views5 pages

Optimal Tracking Filters Ehlers

The document discusses optimal tracking filters for estimating the position of a target using a linear model. It provides the mathematical equations for sub-optimal alpha and alpha-beta filters, and describes how to compute the tracking index and optimal values for alpha based on uncertainties. An example optimum tracking filter is shown to outperform traditional filters by adjusting rapidly yet remaining smooth in sideways markets.

Uploaded by

Frank Abraham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
297 views5 pages

Optimal Tracking Filters Ehlers

The document discusses optimal tracking filters for estimating the position of a target using a linear model. It provides the mathematical equations for sub-optimal alpha and alpha-beta filters, and describes how to compute the tracking index and optimal values for alpha based on uncertainties. An example optimum tracking filter is shown to outperform traditional filters by adjusting rapidly yet remaining smooth in sideways markets.

Uploaded by

Frank Abraham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

OPTIMAL TRACKING FILTERS

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.

1) X^ = X^[1] + (Z – X^[1])


Where X^ is the estimated next position
Z is the last real position

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:

2) EMA = *Price + (1 – )*EMA[1]

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:

3) X^ = X^[1] + ((Z + K*V^) – X^[1])


Where V^ is the velocity estimate
K is a gain factor

In general, the velocity estimate is an EMA of the rate of change of position, so that:

4) V^ = V^[1] + (V – V^[1])

This is the Beta part of an Alpha-Beta filter.


We can create a near zero lag filter for the special case where b = 1. In this
case, equation 2 can be written as:

5) ZEMA = *(Price + K*(Price – Price[4])) + (1 – )*ZEMA[1]

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:

7)  = (position maneuverability uncertainty) / (position measurement uncertainty)

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  162 )

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   )

COMPUTING THE TRACKING INDEX


Under steady state conditions the position maneuverability uncertainty is just
the bar-to-bar variation of the mid range of the price bars. The measurement
uncertainty is half the high-to-low range of the price bar. Simple enough. As a practical
matter, is it better to take the Exponential Moving Averages of these two measurements
to keep the Tracking Factor from going completely crazy. A smoothing constant of .2
results in reasonable a four bar lag2 in both the numerator and denominator,
fundamentally canceling lag in the ratio. Therefore, the simplified equations for the
Tracking Factor in terms of the price is:

10) A = .2*((H+L)/2 – (H[1]+L[1])/2) + .8*A[1]


B = .2*(H-L)/2 + .8*B[1]
=A/B
The EasyLanguage source code for an optimal tracking filter is given in SideBar1.

************************************** SideBar 1 *******************************************


EasyLanguage Code for an Optimal Tracking Filter

inputs:Price((h+l)/2);

vars: lambda(0),
alpha(0);

Value1 = .2*(Price - Price[1]) + .8*Value1[1];


Value2 = .1*(H - L) + .8*Value2[1];
if Value2 <>0 then lambda = AbsValue(Value1 / Value2);
alpha = ( -lambda*lambda + SquareRoot(lambda*lambda*lambda*lambda +
16*lambda*lambda)) /8;
Value3 = alpha*Price + (1-alpha)*Value3[1];

Plot1(Value3, "AlphaTrack");

OPTIMUM TRACKING FILTER EXAMPLE


Returning to the same price data used in Figure 1 to plot the zero lag filter, we
see that the Optimum Tracking Filter quickly adjusts rapid shifts in the price and yet is

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

Figure 2. Optimum Tracking Filter

You might also like