petergluis
Active member
I converted Stochastic Weighted Moving Averages for ThinkorSwim.
https://www.tradingview.com/script/GkTUBQJ3-Stochastic-Weighted-Moving-Averages-DW/
https://www.tradingview.com/script/GkTUBQJ3-Stochastic-Weighted-Moving-Averages-DW/
Ruby:
#https://www.tradingview.com/script/GkTUBQJ3-Stochastic-Weighted-Moving-Averages-DW/
#by Donovan Wall
def src = hlc3;
def kper = 13;
def dper = 3;
def k = 100*(src - lowest(src, kper))/(highest(src, kper) - lowest(src, kper));
def wk = src*k;
def kwma = sum(wk, kper)/sum(k, kper);
def dwma = average(kwma, dper);
def ut = (kwma > dwma) and (src > kwma) and (src > dwma) and (src > src[1]);
def dt = (kwma < dwma) and (src < kwma) and (src < dwma) and (src < src[1]);
def upb = (kwma > dwma) and (src > kwma) and (src > dwma) and (src < src[1]);
def dpb = (kwma < dwma) and (src < kwma) and (src < dwma) and (src > src[1]);
plot kplot = kwma;
kplot .DefineColor("UpTrend", Color.GREEN);
kplot.DefineColor("DownTrend", Color.RED);
kplot.SetLineWeight(3);
kplot.SetPaintingStrategy(PaintingStrategy.LINE);
kplot.SetStyle(Curve.FIRM);
kplot.AssignValueColor(if kplot > kplot[1] then kplot.Color("UpTrend") else kplot.Color("DownTrend"));
plot dplot = dwma;
dplot.AssignValueColor(if dplot > dplot[1] then dplot.Color("UpTrend") else dplot.Color("DownTrend"));
addcloud (kplot, dplot, color.green, color.red);
Last edited by a moderator: