{Function = Kalman Filter}
{Use gain between 500 to 1000 for starters...}
Inputs: price(NumericSeries), gain(Numeric);
Vars: Pred(price), Smooth(0), Velo(0), DeltaK(0), stderr(0),
error(0), sumerr(0) ;
if currentbar > 1 then
begin
DeltaK = price - Pred;
Smooth = Pred + DeltaK* SquareRoot((gain / 10000) * 2) ;
Velo= Velo + ((gain / 10000) * Deltak) ;
Pred = Smooth + Velo ;
KF=Pred;
end;
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Porting Kalman Filter
Collapse
X
-
Porting Kalman Filter
this is a tradestation function code,is some experienced of C# able to do its porting?
Code:Last edited by Mauro60; 09-17-2007, 06:43 AM.Tags: None
-
Kalman Filter Conversion
I don't know Trade Station, so I'm not sure I got this right.
But I converted it....
It seems to be touchy about the value of "gain", either plotting just a horizontal line if too small, or nothing at all if too big.Code:private int gain = 500; double pred; double velo = 0; protected override void Initialize() { Add(new Plot(Color.Orange, "Kalman")); Overlay = true; PriceTypeSupported = true; } protected override void OnBarUpdate() { if (CurrentBar == 0) pred = Close[0]; // Initialize on first bar. double DeltaK = Close[0] - pred; double smooth = pred + DeltaK * Math.Sqrt(( gain / 10000) * 2); velo = velo + ((gain / 10000) * DeltaK); pred = smooth + velo; Values[0].Set( pred ); }
Let me know if this is what its supposed to do (see attachments).
Best regards,
KBJ
-
Kalman Filter
This post was from a while ago. I wanted to see if anyone else had a Kalman Filter indicator that they are using. Any help would be appreciated.
Thanks.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by SalmaTrader, 07-07-2026, 10:26 PM
|
0 responses
24 views
0 likes
|
Last Post
by SalmaTrader
07-07-2026, 10:26 PM
|
||
|
Started by CarlTrading, 07-05-2026, 01:16 PM
|
0 responses
14 views
0 likes
|
Last Post
by CarlTrading
07-05-2026, 01:16 PM
|
||
|
Started by CaptainJack, 06-17-2026, 10:32 AM
|
0 responses
9 views
0 likes
|
Last Post
by CaptainJack
06-17-2026, 10:32 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:15 AM
|
0 responses
10 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:15 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:06 AM
|
0 responses
17 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:06 AM
|

Comment