DeMark 9 For ThinkOrSwim

halcyonguy

Moderator - Expert
VIP
Lifetime
Tom Demark Sequential 9 (TDS 9) is a technical indicator that helps identify a possible trend change. Specifically, if 9 consecutive candles close higher than the previous four, a reversal or correction in a stock's trend is possible.

Ruby:
# demark9_01

#addlabel(1, "demark9_0", color.white);

# https://usethinkscript.com/threads/convert-tradingview-demark-9.11212/
#Convert Tradingview DeMark 9

#//DeMark_9_Indicator_Wealth_Insider
#study("DeMark9 Indicator",overlay=true)
#TD = close > close[4] ?nz(TD[1])+1:0
#TS = close < close[4] ?nz(TS[1])+1:0
#TDUp = TD - valuewhen(TD < TD[1], TD , 1 )
#TDDn = TS - valuewhen(TS < TS[1], TS , 1 )
#plotshape(TDUp==7?true:na,style=shape.triangledown,text="7",color=green,location=location.abovebar)
#plotshape(TDUp==8?true:na,style=shape.triangledown,text="8",color=green,location=location.abovebar)
#plotshape(TDUp==9?true:na,style=shape.triangledown,text="??",color=green,location=location.abovebar)
#plotshape(TDDn==7?true:na,style=shape.triangleup,text="7",color=red,location=location.belowbar)
#plotshape(TDDn==8?true:na,style=shape.triangleup,text="8",color=red,location=location.belowbar)
#plotshape(TDDn==9?true:na,style=shape.triangleup,text="?",color=red,location=location.belowbar)

#------------------------------
input bubbles_on = yes;
# ------------------------------

script ValueWhen {
# look for a previous occurance of a value, and return the value of a diff var
#  valuewhen(condition, return_var, nth occurrence)
#  nth occurrence, original pine code starts n at 0, so 1 is the 2nd
input cond = 0;
input pr = 0;
input n2 = 0;

def n = n2 + 1;
# start at 0 so it looks at current bar
def offset2 = fold j = 0 to 200
with p
while p < n + 1
do p + ( if p == n then j-n else if getvalue(cond, j) then 1 else 0 );
# def bnz = bn - offset2 + 1;
plot price = getvalue(pr, offset2-1);
plot offset = offset2;
}


#-------------------------------
script nz {
 # test if number is valid
 input a = 0;
 def b = if isnan(a) then 0 else a;
 plot c = b;
};
#-------------------------------

def bn = barnumber();
input prev_n_cond = 1;
addlabel(1, "prev n cond " +  prev_n_cond, color.yellow);

#TD = close > close[4] ?nz(TD[1])+1:0
#TS = close < close[4] ?nz(TS[1])+1:0

def td_cls4 = close > close[4];
def ts_cls4 = close < close[4];

def TD = if close > close[4] then nz(TD[1])+1 else 0;
def TS = if close < close[4] then nz(TS[1])+1 else 0;


#  valuewhen(condition, return_price, nth occurrence)
#  n starts at 0, so 1 would be the 2nd prev occurance
#TDUp = TD - valuewhen(TD < TD[1], TD , 1 )
#TDDn = TS - valuewhen(TS < TS[1], TS , 1 )
def td1 = TD < TD[1];
def ts1 = TS < TS[1];
def td_vw = valuewhen(TD1, TD , prev_n_cond).price;
def ts_vw = valuewhen(TS1, TS , prev_n_cond).price;

#def TDUp = TD - valuewhen(TD1, TD , prev_n_cond);
#def TDDn = TS - valuewhen(TS1, TS , prev_n_cond);
def TDUp = TD - td_vw;
def TDDn = TS - ts_vw;


#plotshape(TDUp==7?true:na,style=shape.triangledown,text="7",color=green,location=location.abovebar)
addchartbubble( (bubbles_on and tdup >= 7 and tdup <= 9), high, tdup, color.green, yes);
#plotshape(TDDn==7?true:na,style=shape.triangleup,text="7",color=red,location=location.belowbar)
addchartbubble( (bubbles_on and tddn >= 7 and tddn <= 9), low, tddn, color.red, no);

#------------------------------------

def pr = valuewhen(TD1, TD , prev_n_cond).price;
def off = valuewhen(TD1, TD , prev_n_cond).offset;
#def pr2 = getvalue(td, off-1);


#def td_vw = valuewhen(TD1, TD , prev_n_cond);
input test1 = no;
addchartbubble(test1, (if td1 or td_cls4 then high*1.004 else low*0.996),
td1 + " td1\n" +
bn + " bn\n" +
pr + " pr\n" +
off + " off\n" +
(bn - off + 1) + " prev\n" +
" " + "\n" +
td_cls4 + " cls4\n" +
td + " td\n" +
td1 + " td1\n" +
td_vw + "\n" +
tdup + " tdup\n"
#pr2 + " pr2\n"
#close + " cls\n" +
#close[4] + " cls4"
, (if td1 then color.cyan else color.gray)
, (if td1 or td_cls4 then yes else no));
#

2DzNYzh.jpg
 
Last edited by a moderator:
What is the proper way to utilize this DeMark 9 Indicator. I have read a little bit about it although this one seems to be slightly different.
 
What is the proper way to utilize this DeMark 9 Indicator. I have read a little bit about it although this one seems to be slightly different.
The DeMark website states:
"The 9 output looks for a series of consecutive price comparisons to define the underlying environment. Generally speaking, these 9 results are often followed by a price reversal, with the impact and duration defined by other elements of the indicator."
https://demark.com/indicators-list/
 
Last edited:
Have you compared this to the built in Sequence indicator? Just curious as I've read of several different 'flavors' of DeMarks stuff
 
Tom Demark Sequential 9 (TDS 9) is a technical indicator that helps identify a possible trend change. Specifically, if 9 consecutive candles close higher than the previous four, a reversal or correction in a stock's trend is possible.

Ruby:
# demark9_01

#addlabel(1, "demark9_0", color.white);

# https://usethinkscript.com/threads/convert-tradingview-demark-9.11212/
#Convert Tradingview DeMark 9

#//DeMark_9_Indicator_Wealth_Insider
#study("DeMark9 Indicator",overlay=true)
#TD = close > close[4] ?nz(TD[1])+1:0
#TS = close < close[4] ?nz(TS[1])+1:0
#TDUp = TD - valuewhen(TD < TD[1], TD , 1 )
#TDDn = TS - valuewhen(TS < TS[1], TS , 1 )
#plotshape(TDUp==7?true:na,style=shape.triangledown,text="7",color=green,location=location.abovebar)
#plotshape(TDUp==8?true:na,style=shape.triangledown,text="8",color=green,location=location.abovebar)
#plotshape(TDUp==9?true:na,style=shape.triangledown,text="??",color=green,location=location.abovebar)
#plotshape(TDDn==7?true:na,style=shape.triangleup,text="7",color=red,location=location.belowbar)
#plotshape(TDDn==8?true:na,style=shape.triangleup,text="8",color=red,location=location.belowbar)
#plotshape(TDDn==9?true:na,style=shape.triangleup,text="?",color=red,location=location.belowbar)

#------------------------------
input bubbles_on = yes;
# ------------------------------

script ValueWhen {
# look for a previous occurance of a value, and return the value of a diff var
#  valuewhen(condition, return_var, nth occurrence)
#  nth occurrence, original pine code starts n at 0, so 1 is the 2nd
input cond = 0;
input pr = 0;
input n2 = 0;

def n = n2 + 1;
# start at 0 so it looks at current bar
def offset2 = fold j = 0 to 200
with p
while p < n + 1
do p + ( if p == n then j-n else if getvalue(cond, j) then 1 else 0 );
# def bnz = bn - offset2 + 1;
plot price = getvalue(pr, offset2-1);
plot offset = offset2;
}


#-------------------------------
script nz {
 # test if number is valid
 input a = 0;
 def b = if isnan(a) then 0 else a;
 plot c = b;
};
#-------------------------------

def bn = barnumber();
input prev_n_cond = 1;
addlabel(1, "prev n cond " +  prev_n_cond, color.yellow);

#TD = close > close[4] ?nz(TD[1])+1:0
#TS = close < close[4] ?nz(TS[1])+1:0

def td_cls4 = close > close[4];
def ts_cls4 = close < close[4];

def TD = if close > close[4] then nz(TD[1])+1 else 0;
def TS = if close < close[4] then nz(TS[1])+1 else 0;


#  valuewhen(condition, return_price, nth occurrence)
#  n starts at 0, so 1 would be the 2nd prev occurance
#TDUp = TD - valuewhen(TD < TD[1], TD , 1 )
#TDDn = TS - valuewhen(TS < TS[1], TS , 1 )
def td1 = TD < TD[1];
def ts1 = TS < TS[1];
def td_vw = valuewhen(TD1, TD , prev_n_cond).price;
def ts_vw = valuewhen(TS1, TS , prev_n_cond).price;

#def TDUp = TD - valuewhen(TD1, TD , prev_n_cond);
#def TDDn = TS - valuewhen(TS1, TS , prev_n_cond);
def TDUp = TD - td_vw;
def TDDn = TS - ts_vw;


#plotshape(TDUp==7?true:na,style=shape.triangledown,text="7",color=green,location=location.abovebar)
addchartbubble( (bubbles_on and tdup >= 7 and tdup <= 9), high, tdup, color.green, yes);
#plotshape(TDDn==7?true:na,style=shape.triangleup,text="7",color=red,location=location.belowbar)
addchartbubble( (bubbles_on and tddn >= 7 and tddn <= 9), low, tddn, color.red, no);

#------------------------------------

def pr = valuewhen(TD1, TD , prev_n_cond).price;
def off = valuewhen(TD1, TD , prev_n_cond).offset;
#def pr2 = getvalue(td, off-1);


#def td_vw = valuewhen(TD1, TD , prev_n_cond);
input test1 = no;
addchartbubble(test1, (if td1 or td_cls4 then high*1.004 else low*0.996),
td1 + " td1\n" +
bn + " bn\n" +
pr + " pr\n" +
off + " off\n" +
(bn - off + 1) + " prev\n" +
" " + "\n" +
td_cls4 + " cls4\n" +
td + " td\n" +
td1 + " td1\n" +
td_vw + "\n" +
tdup + " tdup\n"
#pr2 + " pr2\n"
#close + " cls\n" +
#close[4] + " cls4"
, (if td1 then color.cyan else color.gray)
, (if td1 or td_cls4 then yes else no));
#

View attachment 14752
Great system..question, it is possible to add arrow instead of the bubble number? example if is 7-8-9 bubble , just show 3 arrow. thank you in advance!
 
change to arrow


Code:
# demark9_01

#addlabel(1, "demark9_0", color.white);

# https://usethinkscript.com/threads/convert-tradingview-demark-9.11212/
#Convert Tradingview DeMark 9

#//DeMark_9_Indicator_Wealth_Insider
#study("DeMark9 Indicator",overlay=true)
#TD = close > close[4] ?nz(TD[1])+1:0
#TS = close < close[4] ?nz(TS[1])+1:0
#TDUp = TD - valuewhen(TD < TD[1], TD , 1 )
#TDDn = TS - valuewhen(TS < TS[1], TS , 1 )
#plotshape(TDUp==7?true:na,style=shape.triangledown,text="7",color=green,location=location.abovebar)
#plotshape(TDUp==8?true:na,style=shape.triangledown,text="8",color=green,location=location.abovebar)
#plotshape(TDUp==9?true:na,style=shape.triangledown,text="??",color=green,location=location.abovebar)
#plotshape(TDDn==7?true:na,style=shape.triangleup,text="7",color=red,location=location.belowbar)
#plotshape(TDDn==8?true:na,style=shape.triangleup,text="8",color=red,location=location.belowbar)
#plotshape(TDDn==9?true:na,style=shape.triangleup,text="?",color=red,location=location.belowbar)

#------------------------------
input bubbles_on = yes;
# ------------------------------

script ValueWhen {
# look for a previous occurance of a value, and return the value of a diff var
#  valuewhen(condition, return_var, nth occurrence)
#  nth occurrence, original pine code starts n at 0, so 1 is the 2nd
    input cond = 0;
    input pr = 0;
    input n2 = 0;

    def n = n2 + 1;
# start at 0 so it looks at current bar
    def offset2 = fold j = 0 to 200
with p
while p < n + 1
do p + ( if p == n then j - n else if GetValue(cond, j) then 1 else 0 );
# def bnz = bn - offset2 + 1;
    plot price = GetValue(pr, offset2 - 1);
    plot offset = offset2;
}


#-------------------------------
script nz {
 # test if number is valid
    input a = 0;
    def b = if IsNaN(a) then 0 else a;
    plot c = b;
}
;
#-------------------------------

def bn = BarNumber();
input prev_n_cond = 1;
AddLabel(1, "prev n cond " +  prev_n_cond, Color.YELLOW);

#TD = close > close[4] ?nz(TD[1])+1:0
#TS = close < close[4] ?nz(TS[1])+1:0

def td_cls4 = close > close[4];
def ts_cls4 = close < close[4];

def TD = if close > close[4] then nz(TD[1]) + 1 else 0;
def TS = if close < close[4] then nz(TS[1]) + 1 else 0;


#  valuewhen(condition, return_price, nth occurrence)
#  n starts at 0, so 1 would be the 2nd prev occurance
#TDUp = TD - valuewhen(TD < TD[1], TD , 1 )
#TDDn = TS - valuewhen(TS < TS[1], TS , 1 )
def td1 = TD < TD[1];
def ts1 = TS < TS[1];
def td_vw = valuewhen(td1, TD , prev_n_cond).price;
def ts_vw = valuewhen(ts1, TS , prev_n_cond).price;

#def TDUp = TD - valuewhen(TD1, TD , prev_n_cond);
#def TDDn = TS - valuewhen(TS1, TS , prev_n_cond);
def TDUp = TD - td_vw;
def TDDn = TS - ts_vw;


#plotshape(TDUp==7?true:na,style=shape.triangledown,text="7",color=green,location=location.abovebar)
#def up1 =   if (bubbles_on  and  TDUp >= 1 and  TDUp <= 1.9) then 1 else 0 ;
def up2 =   if (bubbles_on  and  TDUp >= 7 and  TDUp <= 9) then 1 else 0 ;
plot upArrow =  if  (up1 or up2) then low else Double.NaN;

# AddChartBubble(upArrow, high, TDUp, Color.GREEN, yes);


upArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
upArrow.SetDefaultColor(Color.GREEN);
upArrow.SetLineWeight(1);

#def dn1 =   if (bubbles_on  and  TDDn >= 1 and  TDDn <= 1.9) then 1 else 0 ;
def dn2 =   if (bubbles_on  and  TDDn >= 7 and  TDDn <= 9) then 1 else 0 ;
plot downArrow =  if (dn1 or dn2)  then high else Double.NaN;
## AddChartBubble(downArrow, high, TDDn, Color.yellow, yes);


downArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
downArrow.SetDefaultColor(Color.YELLOW);
downArrow.SetLineWeight(1);
#plotshape(TDDn==7?true:na,style=shape.triangleup,text="7",color=red,location=location.belowbar)


#------------------------------------

def pr = valuewhen(td1, TD , prev_n_cond).price;
def off = valuewhen(td1, TD , prev_n_cond).offset;
#def pr2 = getvalue(td, off-1);


#def td_vw = valuewhen(TD1, TD , prev_n_cond);
input test1 = no;
AddChartBubble(test1, (if td1 or td_cls4 then high * 1.04 else low * 0.95),
td1 + " td1\n" +
bn + " bn\n" +
pr + " pr\n" +
off + " off\n" +
(bn - off + 1) + " prev\n" +
" " + "\n" +
td_cls4 + " cls4\n" +
TD + " td\n" +
td1 + " td1\n" +
td_vw + "\n" +
TDUp + " tdup\n"
#pr2 + " pr2\n"
#close + " cls\n" +
#close[4] + " cls4"
, (if td1 then Color.CYAN else Color.GRAY)
, (if td1 or td_cls4 then yes else no));
#
 
Last edited:

change to arrow


Code:
# demark9_01

#addlabel(1, "demark9_0", color.white);

# https://usethinkscript.com/threads/convert-tradingview-demark-9.11212/
#Convert Tradingview DeMark 9

#//DeMark_9_Indicator_Wealth_Insider
#study("DeMark9 Indicator",overlay=true)
#TD = close > close[4] ?nz(TD[1])+1:0
#TS = close < close[4] ?nz(TS[1])+1:0
#TDUp = TD - valuewhen(TD < TD[1], TD , 1 )
#TDDn = TS - valuewhen(TS < TS[1], TS , 1 )
#plotshape(TDUp==7?true:na,style=shape.triangledown,text="7",color=green,location=location.abovebar)
#plotshape(TDUp==8?true:na,style=shape.triangledown,text="8",color=green,location=location.abovebar)
#plotshape(TDUp==9?true:na,style=shape.triangledown,text="??",color=green,location=location.abovebar)
#plotshape(TDDn==7?true:na,style=shape.triangleup,text="7",color=red,location=location.belowbar)
#plotshape(TDDn==8?true:na,style=shape.triangleup,text="8",color=red,location=location.belowbar)
#plotshape(TDDn==9?true:na,style=shape.triangleup,text="?",color=red,location=location.belowbar)

#------------------------------
input bubbles_on = yes;
# ------------------------------

script ValueWhen {
# look for a previous occurance of a value, and return the value of a diff var
#  valuewhen(condition, return_var, nth occurrence)
#  nth occurrence, original pine code starts n at 0, so 1 is the 2nd
    input cond = 0;
    input pr = 0;
    input n2 = 0;

    def n = n2 + 1;
# start at 0 so it looks at current bar
    def offset2 = fold j = 0 to 200
with p
while p < n + 1
do p + ( if p == n then j - n else if GetValue(cond, j) then 1 else 0 );
# def bnz = bn - offset2 + 1;
    plot price = GetValue(pr, offset2 - 1);
    plot offset = offset2;
}


#-------------------------------
script nz {
 # test if number is valid
    input a = 0;
    def b = if IsNaN(a) then 0 else a;
    plot c = b;
}
;
#-------------------------------

def bn = BarNumber();
input prev_n_cond = 1;
AddLabel(1, "prev n cond " +  prev_n_cond, Color.YELLOW);

#TD = close > close[4] ?nz(TD[1])+1:0
#TS = close < close[4] ?nz(TS[1])+1:0

def td_cls4 = close > close[4];
def ts_cls4 = close < close[4];

def TD = if close > close[4] then nz(TD[1]) + 1 else 0;
def TS = if close < close[4] then nz(TS[1]) + 1 else 0;


#  valuewhen(condition, return_price, nth occurrence)
#  n starts at 0, so 1 would be the 2nd prev occurance
#TDUp = TD - valuewhen(TD < TD[1], TD , 1 )
#TDDn = TS - valuewhen(TS < TS[1], TS , 1 )
def td1 = TD < TD[1];
def ts1 = TS < TS[1];
def td_vw = valuewhen(td1, TD , prev_n_cond).price;
def ts_vw = valuewhen(ts1, TS , prev_n_cond).price;

#def TDUp = TD - valuewhen(TD1, TD , prev_n_cond);
#def TDDn = TS - valuewhen(TS1, TS , prev_n_cond);
def TDUp = TD - td_vw;
def TDDn = TS - ts_vw;


#plotshape(TDUp==7?true:na,style=shape.triangledown,text="7",color=green,location=location.abovebar)
#def up1 =   if (bubbles_on  and  TDUp >= 1 and  TDUp <= 1.9) then 1 else 0 ;
def up2 =   if (bubbles_on  and  TDUp >= 7 and  TDUp <= 9) then 1 else 0 ;
plot upArrow =  if  (up1 or up2) then low else Double.NaN;

# AddChartBubble(upArrow, high, TDUp, Color.GREEN, yes);


upArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
upArrow.SetDefaultColor(Color.GREEN);
upArrow.SetLineWeight(1);

#def dn1 =   if (bubbles_on  and  TDDn >= 1 and  TDDn <= 1.9) then 1 else 0 ;
def dn2 =   if (bubbles_on  and  TDDn >= 7 and  TDDn <= 9) then 1 else 0 ;
plot downArrow =  if (dn1 or dn2)  then high else Double.NaN;
## AddChartBubble(downArrow, high, TDDn, Color.yellow, yes);


downArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
downArrow.SetDefaultColor(Color.YELLOW);
downArrow.SetLineWeight(1);
#plotshape(TDDn==7?true:na,style=shape.triangleup,text="7",color=red,location=location.belowbar)


#------------------------------------

def pr = valuewhen(td1, TD , prev_n_cond).price;
def off = valuewhen(td1, TD , prev_n_cond).offset;
#def pr2 = getvalue(td, off-1);


#def td_vw = valuewhen(TD1, TD , prev_n_cond);
input test1 = no;
AddChartBubble(test1, (if td1 or td_cls4 then high * 1.04 else low * 0.95),
td1 + " td1\n" +
bn + " bn\n" +
pr + " pr\n" +
off + " off\n" +
(bn - off + 1) + " prev\n" +
" " + "\n" +
td_cls4 + " cls4\n" +
TD + " td\n" +
td1 + " td1\n" +
td_vw + "\n" +
TDUp + " tdup\n"
#pr2 + " pr2\n"
#close + " cls\n" +
#close[4] + " cls4"
, (if td1 then Color.CYAN else Color.GRAY)
, (if td1 or td_cls4 then yes else no));
#
thank you very much @mmm777 , the arrow is not line up with the bubble, is a lot of arrow compare to the bubble. thank you in advance.
 
Last edited by a moderator:
Is this similar to the "Sequence Counter" study in ThinkorSwim?
Have you compared this to the built in Sequence indicator? Just curious as I've read of several different 'flavors' of DeMarks stuff

You could say that the ToS sequence counter and Demark 9 Theory and the other 'flavors' of DeMarks stuff are similar. They all look for when a sequence of consecutive candles close higher than the previous four.

This pattern is thought to signal an overextended price move, one that is likely to change direction.
The DeMark 9 espouses that the magic number for the sequence is 9
 
Last edited:
can it mark NO 1?
You can use the ToS Sequence Counter to easily find number 1.

DeMark is the similar to the ToS Sequence Counter; except it is set up to specifically find the overextended move in the higher sequence counts.
So no, it is not meant to find number one.
 
Last edited:
You can use the ToS Sequence Counter to easily find number 1.

DeMark is the similar to the ToS Sequence Counter; except it is set up to specifically find the overextended move in the higher sequence counts.
Thanks for the clarifications on the difference.
 
is there a way to use this in a scan since theres not a plot that i could use? thanks

for when the demark hits 9 so the trend is possibly over and theres a reversal coming thanks
 
Last edited by a moderator:
For example, I'd like to scan for all 9's (bubbles) appearing within graphs of various symbols on the daily time frame, as this classic strategy produces a healthy APR and Win Rate% over a 10 year period, outperforming the SPY handily, but I'd like to do more back testing analysis with the ability to scan for 9's within TOS. Is that possible? Scanning in this way does not appear to be possible using the script above. Thx
Were you able to scan for number nine? I'd like to do the same.
 
For example, I'd like to scan for all 9's (bubbles) appearing within graphs of various symbols on the daily time frame, as this classic strategy produces a healthy APR and Win Rate% over a 10 year period, outperforming the SPY handily, but I'd like to do more back testing analysis with the ability to scan for 9's within TOS. Is that possible? Scanning in this way does not appear to be possible using the script above. Thx

No, no one replied to my original request.
 
Last edited by a moderator:
For example, I'd like to scan for all 9's (bubbles) appearing within graphs of various symbols on the daily time frame, as this classic strategy produces a healthy APR and Win Rate% over a 10 year period, outperforming the SPY handily, but I'd like to do more back testing analysis with the ability to scan for 9's within TOS. Is that possible? Scanning in this way does not appear to be possible using the script above. Thx
for when the demark hits 9 so the trend is possibly over and theres a reversal coming thanks
Were you able to scan for number nine? I'd like to do the same.
To create a scan:

replace these lines of code:
def TDUp = TD - td_vw;
def TDDn = TS - ts_vw;
with these:
plot TDUp = TD - td_vw;
plot TDDn = TS - ts_vw;

scan condition is:
tdup == 9
or
tddn == 9

Here is a tutorial for how to set up your scan condition in the scan hacker:
https://usethinkscript.com/threads/how-to-use-thinkorswim-stock-hacker-scans.284/
 
Last edited:
can it mark NO 1?
it could. The code is looking to start the bubble count at tdup or tddn >=7. You could lower that number.

#plotshape(TDUp==7?true:na,style=shape.triangledown,text="7",color=green,location=location.abovebar)
addchartbubble( (bubbles_on and tdup >= 7 and tdup <= 9), high, tdup, color.green, yes);
#plotshape(TDDn==7?true:na,style=shape.triangleup,text="7",color=red,location=location.belowbar)
addchartbubble( (bubbles_on and tddn >= 7 and tddn <= 9), low, tddn, color.red, no);
 
To create a scan:

change these lines of code:

to:


scan condition is:

or


Here is a tutorial for how to set up your scan condition in the scan hacker:
https://usethinkscript.com/threads/how-to-use-thinkorswim-stock-hacker-scans.284/

Errors when changing that code to the new values:


Identifier Already Used: TDUp at 95:5
Identifier Already Used: TDDn at 96:5
Expected double at 90:13
Expected double at 91:13
Expected double at 106:10
Expected double at 107:11
Expected double
No such variable: td_vw at 85:18
No such variable: ts_vw at 86:18
No such variable: TD1 at 90:23
No such variable: TS1 at 91:23
Already assigned: TDUp at 95:5
Already assigned: TDDn at 96:5
No such variable: TD1 at 106:20
No such variable: TD1 at 107:21
No such variable: td1 at 113:27
No such variable: td1 at 114:1
No such variable: td1 at 122:1


Also I think you meant tddn >= 9 instead of tddn <= 9 (less than 9 would always be true?)
 
Errors when changing that code to the new values:


Identifier Already Used: TDUp at 95:5
Identifier Already Used: TDDn at 96:5
Expected double at 90:13
Expected double at 91:13
Expected double at 106:10
Expected double at 107:11
Expected double
No such variable: td_vw at 85:18
No such variable: ts_vw at 86:18
No such variable: TD1 at 90:23
No such variable: TS1 at 91:23
Already assigned: TDUp at 95:5
Already assigned: TDDn at 96:5
No such variable: TD1 at 106:20
No such variable: TD1 at 107:21
No such variable: td1 at 113:27
No such variable: td1 at 114:1
No such variable: td1 at 122:1


Also I think you meant tddn >= 9 instead of tddn <= 9 (less than 9 would always be true?)
Your errors are not possible if you followed the directions.

1. copy & paste the study from https://usethinkscript.com/threads/demark-9-for-thinkorswim.11212/#post-99312
2. how to copy & paste: https://usethinkscript.com/threads/how-to-import-existing-thinkscript-code-on-thinkorswim.10/


To create a scan:

replace these lines of code:
def TDUp = TD - td_vw;
def TDDn = TS - ts_vw;
with these:
plot TDUp = TD - td_vw;
plot TDDn = TS - ts_vw;

scan condition is:
tdup == 9
or
tddn == 9

Here is a tutorial for how to set up your scan condition in the scan hacker:
https://usethinkscript.com/threads/how-to-use-thinkorswim-stock-hacker-scans.284/

It is not possible to say where you went astray.
A wild guess would be that you ADDED the code instead of REPLACING the code.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
258 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top