MetaStock™ Zone Forum & FAQ Artykuły Linki Elliott Waves EasyLanguage™ Zone

 

Kalman Filter
Smoothing with a Kalman Filter

. To: Omega-list <omega-list@xxxxxxxxxx>
. Subject: Smoothing with a Kalman Filter
. From: Randall Kurzon <rkurzon@xxxxxxxxxxxxx>
. Date: Fri, 28 Aug 1998 12:06:06 -0400
. Resent-Date: Fri, 28 Aug 1998 09:05:42 -0700
. Resent-From: omega-list@xxxxxxxxxx
. Resent-Message-ID: <"CWrfD2.0.PB2.MLjvr"@mx1>
. Resent-Sender: omega-list-request@xxxxxxxxxx

I have found that I seem to accomplish fairly good smoothing with a limited amount of lag using a Kalman filter. I just tried this on the code posted by Thomas Stridsman for the $%B indicator and thought perhaps others might wish to do the same. Below is the function I use for the Kalman filter. A good starting point for K1 is about 800.

Comments?

Regards, Randall

{Function name= KF}

INPUT: K1(Numeric),Price(NumericSeries);
VARS:Pred(BP),Smooth(0),Velo(0),DeltaK(0),stderr(0),error(0),sumerr(0);

IF currentbar > 1 then BEGIN

DeltaK = BP -Pred;
Smooth = Pred + DeltaK* SquareRoot( (K1/10000)*2 ) ;
Velo= Velo + ((K1/10000)*Deltak) ;
Pred = Smooth + Velo ;

KF=Pred;
END;

[9770]

Re: Smoothing with a Kalman Filter

. To: Randall Kurzon <rkurzon@xxxxxxxxxxxxx>, omega-list@xxxxxxxxxx
. Subject: Re: Smoothing with a Kalman Filter
. From: "Gerrit Jacobsen" <jrt@xxxxxxxxxx>
. Date: Fri, 28 Aug 1998 17:09:41 +0100
. Organization: JRT
. Priority: normal
. Reply-to: Gerrit.Jacobsen@xxxxxxxxxxxxx
. Resent-Date: Fri, 28 Aug 1998 09:26:48 -0700
. Resent-From: omega-list@xxxxxxxxxx
. Resent-Message-ID: <"YeNW72.0.XX4.7fjvr"@mx1>
. Resent-Sender: omega-list-request@xxxxxxxxxx

Randall,

> I have found that I seem to accomplish fairly good smoothing with a
> limited amount of lag using a Kalman filter.
> Comments?

I have had very limited success with the univariate Kalman filter so far. I wanted to use it as a data-filter before feeding it into other indicators. I could not find that it improves the data. I get the impression that the "noise" IS the real thing and filtering does not help.

Graham send me recently this URL for some multivariate code. I would love to test it but so far did not have the time to do so.

www.cms.dmu.ac.uk/~cph/Public/kalman++.code

Somehow I doubt that prefiltering helps with financial data. Important are the indicators and no amount of filters can improve them. I have found that the more I filter and I mean even go away from 1 tick data or even time-based data (which is somehow a filter as well) I get worse results.

This effect is sometimes not obvious because one has to distinguish between the analysis of the data and the trading strategy. Because of your reaction time, transaction costs it might be worthwhile to see the trading based on a different time frame then the analysis.

So sometimes one gets better TRADING (simulation) results because the filters produce less trades which results in less transaction cost.

Gerrit

Gerrit Jacobsen
http://www.tickscape.com

[9771]

Smoothing with a Kalman Filter- take 2

. To: Omega-list <omega-list@xxxxxxxxxx>
. Subject: Smoothing with a Kalman filter- take 2
. From: Randall Kurzon <rkurzon@xxxxxxxxxxxxx>
. Date: Fri, 28 Aug 1998 14:43:14 -0400
. Resent-Date: Fri, 28 Aug 1998 11:42:50 -0700
. Resent-From: omega-list@xxxxxxxxxx
. Resent-Message-ID: <"-JC0Y.0.TH1.gelvr"@mx1>
. Resent-Sender: omega-list-request@xxxxxxxxxx

A small error in the code as posted was brought to my attention. I apologize for any inconvenience it may have caused. It should be:


Type : Function, Name : Kalman Filter

{Function name= KF}
INPUT:
K1(Numeric),
BP(NumericSeries);
VARS:
Pred(BP),
Smooth(0),
Velo(0),
DeltaK(0),
stderr(0),
error(0),
sumerr(0) ; IF currentbar > 1 then BEGIN

DeltaK = BP -Pred;
Smooth = Pred + DeltaK* SquareRoot( (K1/10000)*2 ) ;
Velo= Velo + ((K1/10000)*Deltak) ;
Pred = Smooth + Velo ;

KF=Pred;
END;

 

Source / From: TOP
http://www.purebytes.com

TradeStation® Pro, TradeStation® 2000i, OptionStation®, SuperCharts®, PowerEditor® and EasyLanguage®
are registered trademarks of TradeStation Technologies, Inc. Other names and marks referred to are the property of their respective owners.

All information provided on this website is for educational purposes only. Trading involves risk, including possible loss of principal and other losses.

Ten i inne materiały na tej stronie zostały zamieszczone zostały jedynie w celach edukacyjnych, nie ponoszę żadnej odpowiedzialno¶ci za ich stosowanie.

Gra na giełdzie i rynkach walutowych (FOREX) niesie ze sob± ryzyko poważnych strat finansowych!