This is the ToS Moving Average Difference with some lipstick added.
This provides similar but not as good data as:
https://usethinkscript.com/threads/donchian-channel-trend-for-thinkorswim.11848/#post-102682
But a member requested this one so here it is:
This provides similar but not as good data as:
https://usethinkscript.com/threads/donchian-channel-trend-for-thinkorswim.11848/#post-102682
But a member requested this one so here it is:
Ruby:
# ################################
def mad = reference MAD("fast length" = 9, "slow length" = 27)."MAD";
# ################################
# Charting & Formatting
declare lower ;
declare real_size ;
plot pMAD = mad ;
pMAD.SetLineWeight(2);
pMAD.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
# pMAD.AssignValueColor(if mad>0 then color.green else color.red);
plot zeroline = 0;
zeroline.SetPaintingStrategy(PaintingStrategy.DASHES);
zeroline.SetDefaultColor(color.violet);
# ################################
# Tutorial to color plots
# ################################
DefineGlobalColor("color1", color.green) ;
DefineGlobalColor("color2", color.pink) ;
DefineGlobalColor("color3", color.red) ;
DefineGlobalColor("color4", color.dark_green) ;
#def NameOfPlot = #put the name of the plot you want to color here ;
def NameOfPlot = mad ;
#def signal = #put the name of the demarcation of over / under ;
def signal = 0 ;
def pos = NameOfPlot>= signal;
def neg = NameOfPlot< signal;
def up = NameOfPlot >= NameOfPlot[1];
def dn = NameOfPlot < NameOfPlot[1];
def PosUp = pos and up;
def PosDn = pos and dn;
def NegDn = neg and dn;
def NegUp = neg and up;
pmad.AssignValueColor(
if PosUp then GlobalColor("color1") else
if PosDn then GlobalColor("color2") else
if NegDn then GlobalColor("color3") else
if NegUp then GlobalColor("color4") else Color.gray) ;
Last edited: