please help,
I am looking for ttmwave1, ttmwave2high and ttmwave2low, crossing above/below zero line, countconsecutive with labels green crossing above, red crossing below
Thank you
it is unclear what you want to see.
i think you want a watchlist column?
3 main questions to answer,
1. where do you want to see something?
2. what do you want to see?
3. when do you want to see something?
1. i think watchlist column
2. i have no idea
3. when a crossing occurs
so, we have to figure out #2.
you want,
to track 3 variables,
a red or green on a crossing
count something...
i don't know what count consecutive means? count what? when?
i don't know if you want 3 separate columns to track each plot variable?
or all combined into 1 column?
---------------------------
this is a lower study, that should help you decide what you want to see.
it combines all 3 plot signals into 1 label.
also has 3 separate labels.
the labels turn red or green on a crossing.
3 numbers show the count of bars , back to a recent crossing.
. they start at 1 or -1 on a crossing.
. positive numbers if a cross up
. negative numbers if a cross down
https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/T-U/TTM-Wave
Code:
# col_ttmwave_crossings_00_lower
#https://usethinkscript.com/threads/ttmwave-custom-column.14545/
#I am looking for ttmwave1, ttmwave2high and ttmwave2low, crossing above/below zero line, count consecutive with labels green crossing above, red crossing below
#this combines all 3 into 1 col
#red green on cross
#3 numbers show the count of bars , back to a recent cross , for the 3 plots.
#they start at 1 or -1 on a cross
#pos# if was up
#neg# if was dwn
#--------------
declare lower;
def bn = barnumber();
def na = Double.NaN;
def w1 = TTM_Wave().Wave1;
def w2hi = TTM_Wave().Wave2High;
def w2lo = TTM_Wave().Wave2Low;
def wz = TTM_Wave().ZeroLine;
input show_lines = yes;
plot z1 = if show_lines then w1 else na;
plot z2 = if show_lines then w2hi else na;
plot z3 = if show_lines then w2lo else na;
plot z4 = if show_lines then wz else na;
# count from recent crossing,
#. cnt pos after a cross up
#. cnt neg after a cross down
def w1x = if bn == 1 then 0
else if w1 crosses above wz then 1
else if w1 crosses below wz then -1
else w1x[1] + sign(w1x[1]) ;
def w2hix = if isnan(w2hix[1]) or bn == 1 then 0
else if w2hi crosses above wz then 1
else if w2hi crosses below wz then -1
else w2hix[1] + sign(w2hix[1]) ;
def w2lox = if bn == 1 then 0
else if w2lo crosses above wz then 1
else if w2lo crosses below wz then -1
else w2lox[1] + sign(w2lox[1]) ;
#assignbackgroundcolor(
#if (w1x == 1 or w2hix == 1 or w2lox == 1) then color.green
#else if (w1x == -1 or w2hix == -1 or w2lox == -1) then color.red
#else color.gray);
#------------------------
addlabel(1,
((if w1x > 0 then " " else "") +
w1x + " | " +
(if w2hix > 0 then " H" else "H") +
w2hix + " | " +
(if w2lox > 0 then " L" else "L") +
w2lox)
, color.yellow);
#, color.black);
#------------------------
addlabel(1, " ", color.black);
addlabel(1,
"wave1 " + (if w1x > 0 then " " else "") + w1x
, if w1x == 1 then color.green else if w1x == -1 then color.red else color.gray);
#------------------------
addlabel(1, " ", color.black);
addlabel(1,
"wave2 hi " + (if w2hix > 0 then " " else "") + w2hix
, if w2hix == 1 then color.green else if w2hix == -1 then color.red else color.gray);
#------------------------
addlabel(1, " ", color.black);
addlabel(1,
"wave2 lo " + (if w2lox > 0 then " " else "") + w2lox
, if w2lox == 1 then color.green else if w2lox == -1 then color.red else color.gray);
#-------------------------
#