Convert Kalman Filter to ThinkorSwim?

ebtrader

New member
Anyone try coding the Kalman Filter? EasyLanguage version is out there but I have yet to see someone able to convert it to ThinkScript.
 

tomsk

Well-known member
VIP
Here's a Kalman that I have from a while back

input n = 21;

plot Kalman = WMA(((WMA(close, 3) * 3) + (WMA(close[1], 2) * 2) + close[2] + Average(close, n)) / 7, n);
 

codydog

Active member
# Simple Kalman Filter Compared to different Averages
# Mobius
# 2.22.2016

input n = 8;
input Kalman = yes;
input SMA = yes;
input EMA = yes;
input Weighted_MA = yes;

plot Data = WMA(((close * 3) + (close[1] * 2) + close[2] + Average(close, n)) / 7, n);
Data.SetDefaultColor(Color.Cyan);
Data.SetHiding(!Kalman);
AddLabel(1, "Kalman Filter", Color.Cyan);

plot avg = Average(close, n);
avg.SetDefaultColor(Color.Yellow);
avg.SetHiding(!SMA);
AddLabel(1, "SMA", Color.Yellow);

plot ExAvg = ExpAverage(close, n);
ExAvg.SetDefaultColor(Color.Red);
ExAvg.SetHiding(!EMA);
AddLabel(1, "EMA", Color.Red);

plot WtAvg = WMA(close, n);
WtAvg.SetDefaultColor(Color.Green);
WtAvg.SetHiding(!Weighted_MA);
AddLabel(1, "Weighted MA", Color.Green);
 

codydog

Active member
Don't know why, but I have Kolmogorov-Feller linked to Kalman - curious cross-overs

declare lower;
input n = 20;
def s = fold i = 1 to n with d = 0 do d+log(i);
def f = fold j = 1 to n with m = 0 do m+log(getvalue(close,j,n))*log(j);
def k = fold g = 1 to n with c = 0 do c+power(log(g),2);
def alpha = ((Sum(log(Close),n)*s) - (n*f))/((s*s)-n*k);
def a = exp(((Sum(Close,n)-alpha*s)/n)/1000);
plot al = a;

al.assignvaluecolor(if al > al[1] then color.blue else if al < al[1] then color.red else color.white);
plot trig = al[1];

#Blackledge "FINANCIAL FORECASTING USING THE
#KOLMOGOROV-FELLER EQUATION"
#growex

plot Data = WMA(((a * 3) + (a[1] * 2) + a[2] + Average(a, n)) / 7, n);
Data.SetDefaultColor(Color.Cyan);
 

Similar threads

Top