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

Re: improvements for "catscan" & other systems


  • To: Steve80866@xxxxxxx
  • Subject: Re: improvements for "catscan" & other systems
  • From: Bob Fulks <bfulks@xxxxxxxxxxxx>
  • Date: Sun, 9 May 1999 10:23:42 -0400 (EDT)
  • In-reply-to: <585e103.2466695d@xxxxxxx>

PureBytes Links

Trading Reference Links


At 7:44 PM -0400 5/8/99, MRLYNNG@xxxxxxx wrote quoting Bob Fulks:

>
>  I almost always end up working directly with the price to find the
>  characteristic I am looking for in real time. I often use digital filters
>  to spot the event well before it becomes apparent to a common indicator,
>  (quite possibly because on my training as an electrical engineer.) A simple
>  example of such a digital filter was a trading system published by Bob
>  Brickey about two years ago (code slightly simplified by me):
>

At 12:30 AM -0400 5/9/99, Steve80866@xxxxxxx wrote:

>Could someone enlighten me as to what a "digital filter" is?



The name "digital filter" is used to distinguish the technique from those
used in "analog filters".

In the "good old days" before computers were so cheap, electrical engineers
designed filters, such as those used in the tone controls of your "hi fi"
set, and in telephone systems to eliminate crosstalk between telephone
conversations, using "analog" electronic components such as resistors,
inductors, and capacitors (those funny little things that are soldered into
the printed circuit boards of your TV set).

Around the late 1950's it started to become possible to do the same
functions with digital computer circuitry by converting the sound to a
series of digital numbers representing the value of the signal every few
thousands of a second and then using computers to do what had previously
been done by the analog filters.

Now, of course, essentially all sound processing is done digitally in TV
sets, CD players, satellite TV systems, etc., since digital technology is
now so much cheaper that using analog technology.

So over the years, engineers developed many clever ways to filter signals
using digital techniques to recover meaningful signals from noise.

It turns out that the price bars on your trading program look very similar
to the noisy electrical signals that engineers work with all the time, so
we can transfer this technology to trading applications.

In fact, the common "moving averages" that we all use are very simple
examples of digital filters. They operate by multiplying past values of the
price and past values of the filter output by numbers and adding together
the results.

The general formula for a digital filter is shown below:


       y[0] = b0*p[0] + b1*p[1] + b2*p[2] + b3*p[3] + ....
                      + a1*y[1] + a2*y[2] + a3*y[3] + ....

where

  y[0] = the output of the filter for the current bar
  y[n] = the output of the filter "n" bars ago
  p[0] = the price for the current bar
  p[n] = the price of "n" bars ago
  a0, a1, a2 ... = numbers
  b0, b1, b2 ... = numbers

For a 5 bar simple moving average the numbers would be:

   b0 = b1 = b2 = b3 = b4 = 0.2 and all other numbers = 0

For an exponential moving average of length 5, the numbers would be:

   b0 = 0.33333
   a1 = 0.66667   and all other numbers = 0


The filter example I used in the post you referenced is a little more
complicated:

   b5 =  + .1904762
   b4 =  + .047619
   b3 =  - .0952381
   b2 =  - .40476197
   b1 =  - .0476191
   b0 =  + .3095237   and all other numbers = 0

This filter finds times to buy and sell on daily price bars of the S&P
futures and was designed by Bob Brickey of Scientific Approaches.

A complex filter used in a communications receiver might have 30 or 40 such
numbers.

In some "adaptive moving averages" the numbers might be different for each
bar, depending upon the recent history of the prices. For example, in the
"VIDYA" adaptive moving average the numbers "b0" and "a1" change for each
bar. This introduces a whole new level of complexity.

So all you have to do to design a digital filter is to find the values of
each number. Unfortunately this is not simple and many people have spent
their entire careers working on this problem. Much of the early work was
done at the Bell Telephone Laboratories since the phone company used a lot
of filters in telephone systems.

There are many books on the subject. One of the best simple books is
written by R. W. Hamming, one of the very famous names in the field from
Bell Labs (now Lucent Technology). The book is called "Digital Filter"
(ISBN 0-486-65088-X). It is about a half-inch thick paperback that costs
only $12.95 (cheaper at Amazon.com probably). To really follow it you need
to understand calculus but many of the basic ideas are pretty clearly
expressed in words.

A basic understanding of such filters would help traders better understand
the strengths and weaknesses of the various moving average filters they use
all the time. For example, I recently saw a case where a trading system was
trying to trade a price pattern that tended to have an eight bar cycle from
high to high. But the system was using a simple moving average of Length =
8 to smooth the prices and it turns out that this particular moving average
has absolutely no output for periodic signals with an eight bar period. I
am sure the person who wrote the system just thought he was simple
smoothing the price but he was actually filtering out the very signal he
was trying to trade.

I hope this has been helpful.

Bob Fulks