TradingView
alexgrover
Nov 8, 2018 5:58 PM

Kalman Smoother 

EUR/USDOANDA

Description

A derivation of the Kalman Filter.

Lower Gain values create smoother results.The ratio Smoothing/Lag is similar to any Low Lagging Filters.

The Gain parameter can be decimal numbers.

Kalman Smoothing With Gain = 20



For any questions/suggestions feel free to contact me
Comments
TriddingViewer
It is good to see this indicator behaves like a Kalman filter, however, it can be simplified to a sum of two Exponential Moving Averages of the price and the difference between price and its previous value, thus maybe it is not an authentic Kalman filter:
delta=price-kf[1]
kf=EMA(price,T)+EMA(delta,T)
where T=100 in the posted pine script :)
pjfj
I know the rest of the CC's but velo can someone please enlighten me, thanks
alexgrover
@pjfj, Velo is bandpass filter that is summed to kf, it allow to reduce the lag of the final output. It is useful to see it like the slope of the double exponential smoothing filter.
cookityammy
converted to pine-version 3:
//@version=3
study("Kalman Smoother",overlay=true)
Gain = input(200,type=float)

// changes for conversion from pine-v2 to v3
kf=0.0
velo=0.0

// original-calculation
src = input(close)
dk = src - nz(kf[1],src)
smooth = nz(kf[1],src)+dk*sqrt((Gain/10000)*2)
velo := nz(velo[1],0) + ((Gain/10000)*dk)
kf := smooth+velo
//
plot(kf,color=red,transp=0)
// End
alexgrover
@cookityammy, I don't appreciate pasting lengthy code in the comment section, if you need it converted in version 3 just say so.
sudhir.mehta
Thanks for sharing!! Can you help in converting to //@version=3.
alexgrover
@sudhir.mehta,You are welcome :) I dont know if its possible since Self/Forward referenced variables are no longer supported in version 3
JonathanMcBrine
I would like to read more about the accuracy of Kalman. Do you have any information?
jaggedsoft
This is excellent. Thank you!
More