Page 1 of 1

Butterworth Band Pass Filter

Posted: Mon Jul 14, 2003 9:28 pm
by Chris Murphy
Ok, I have been trying to figure out how to use the Butterworth band pass filter, I've scoured the net and found this equation:

G(w) =
{1+q^-1[ (4cos(w)-cos(lamda)^2)/(1+cos(lamda)^2 - 2cos(lamda)cos(w))]^n}^-1

lamda = center band location;
n = the band form;
q = spread around lamda;

Now I know that w is the input, but what do you input? I've looked everywhere and have done my homework but can't find any help. Does anyone know how to use the Butterworth band pass filter equation?

Posted: Tue Jul 15, 2003 8:56 am
by Hiramhon
The roman letter "w" is being used to signify the greek letter "omega" (lowercase) for typesetting convenience. Lowercase omega is the traditional variable name always used for angular frequency, in radians per second.

Your equation is in the frequency domain: G(w) is the gain as a function of (angular) frequency.

Probably what you really want is an equation in the time domain [or, more properly, the sampled time domain].

There are a couple of signal processing experts on this roundtable: CRM114, Kiwi, batuco9. You can find their writings on the subject by either searching for "signal processing" and/or clicking on this URL: viewtopic.php?p=1755&highlight=signal+processing#1755
Maybe you can PM them to ask for a little free consulting.

Posted: Tue Jul 15, 2003 9:07 am
by damian
ask for a little free consulting

I know nothing about signal processing. I do not even understand the book I bought about it.

However on any other topic I offer unlimited free consultation. That is the main reason why I am here: to ask and to be asked of.

[ Of what value my consulation will be is understandably arguable ]


Posted: Tue Jul 15, 2003 6:20 pm
by Kiwi

I recall butterworth filters from my electrical engineering days but dont understand what the relevance is to trading. Perhaps you could explain that a bit a little more and then we could debate how the elements of trading would be the variables in the filter ... and why it would be better than a lsma, t3 or trendline. Out of the debate might come the answer?


Posted: Wed Jul 16, 2003 9:20 am
by Chris Murphy
Butterworth filters are theoretically a low pass filter, ie MA(X), where the ouput is then the input into a high pass filter, X-MA(X). The equation I listed is the frequency equation. From playing around with it a bit the value w approaches 1 as w approaches lamda. The idea is for the BWFilter to sort through noisy data and give you clear precise signals. My thought is to try and figure out how I can use a BWF to validate a breakout. However, to do this I first need to understand how to use the equation!

Posted: Wed Jul 16, 2003 6:31 pm
by Kiwi
OK. We do have another equivalent to a moving average. Moving averages are basically filters to remove noise (high frequencies) from a data stream (the incoming series of prices). So typically they leave you with the trend by removing the swings (noise). They're like filters in electrical engineering and you'll find a nice example/puzzle of this type posted by Mark Johnson using classic EE filters on this site:

In the case of moving averages the signal filtered is usually the closing price (although sometimes its the average price which might be (C+L+H)/3). Simple moving averages and Exponential Moving averages are just filters with a center frequency (I vaguely recall) of one over twice (or half) their length. So a 6 period moving average filters out frequencies of over 1/12 and thus should be removing faster frequencies (quicker price swings). A 50 period moving average filters frequencies over 1/100 so it removes a lot more noise.

These are low pass filters in that they let low frequencies thru but cut off high frequencies (noise in the signal, which in our case is the price). They are not perfect filters so they dont cut off all the higher frequency noise but they do reduce it a lot.

The downside of said filters is that they introduce delay (look at the lag between the price the ma is filtering and the price itself). So people try to find filters that either reduce the delay (T3 and Jurik work) or improve the rejection of higher frequencies (seen more in Electrical Engineering - actually I think Mark is teaching this so he should jump in and correct me if my recall is faulty) like the Butterworth filter, say.

So, what does all this mean to you :-)

Well, as I said last time, once you figure out how to code it you should compare the outputs with other MAs for your purpose. Also, the frequencies will be quite low (so try input values like 1/5 to 1/100 for the center band lambda)

Also, Butterworth filters can be low pass (like a MA), high pass (noise/swings only not the underlying price trend), or bandpass (only let a certain frequency of swing through). I dont know which one you want :o

To go further (only so much time over coffee in the morning) I refer you to: ... ode14.html

Rocket Science for Traders: Digital Signal Processing Applications by Ehlers.


Posted: Wed Jul 16, 2003 9:03 pm
by damian
To understand Ehlers's book, I solicited the help of my digital signal engineer friend and skiing companion. In the first few pages the book said something like "this book is not designed for engineers wanting to understand trading, it is aimed at getting traders to understand some digital signal concepts". This got him off on the wrong foot and from there on in he seemed quite offended by the book as a whole and my tutoring never got off the ground.

Posted: Mon Jul 21, 2003 1:54 pm
by Chris Murphy
Thanks for all of the replies. I did some testing using the filter and like all other tests that I have done I've come to the conclusion that filters are generally bad. If your system has a positivie expectation then that means that your trades have a positive expectation therefore when you eliminate a trade your eliminating some of your positive expectation. The more I test the more I realize that simplicity is generally the best. I've come to agree with the notion that a good system should fit on one piece of paper and that your time is best spent understanding the proper bet size algorithm and not trade identification.

Posted: Mon Jul 21, 2003 5:48 pm
by Kiwi
Trendprogression, great wisdom there.

I would add that time may also be well spent seeking another simple system that buys and sells at different times to the first system - and is able to smooth your equity curve :-)

This is true whether you use a dimensionless or dimensional quantity to measure it - hmmm must go and post on that subject.

Re: Butterworth Band Pass Filter

Posted: Fri Sep 19, 2003 9:08 am
by Toni

Description: 3-pole Butterworth type Lowpass filter

Provided By: DT (c) 2000


Input: Price(Numericseries), Period(Numericsimple);

Vars: Coeff_a(0), Coeff_b(0), Coeff_c(0), Filter(0);

if Period > 0 then begin

Coeff_a = ExpValue(-3.14159 / Period);

Coeff_b = 2 * Coeff_a * Cosine(1.738 * 180 / Period);


Coeff_c = Coeff_a * Coeff_a;

Filter = (Coeff_b + Coeff_c)* Filter[1] - (Coeff_c + Coeff_b * Coeff_c)* Filter[2] + Coeff_c * Coeff_c * Filter[3] +

((1 - Coeff_b + Coeff_c)*(1 - Coeff_c)* 0.125)*(Price + 3 * Price[1] + 3 * Price[2] + Price[3]);

DT_3Pole_Butterworth = Filter; ... _en&tt=url ... _en&tt=url ... 7;cmd=show

Re: Butterworth Band Pass Filter

Posted: Sat Sep 20, 2003 7:16 am
by Toni
The Scientist and Engineer's Guide to Digital Signal Processing by Steven W. Smith, Ph.D.