reply to 325
another example of chatgpt not knowing how to create a study.
the study only reads 1 plot from the study. there are 3 signals and zero.
just take the time to learn thinkscript.
since the original study is hidden, i had to make some guesses and start experimenting.
i loaded the original study, ttm_wave.
i read the plot values from the original study, and plotted lines.
def w1 = ttm_wave().Wave1;
def w2hi = ttm_wave().Wave2High;
def w2lo = ttm_wave().Wave2Low;
#def z0 = ttm_wave().ZeroLine;
the lines are pretty flat, so its hard to tell when they change direction.
i made a bubble to display the plot values.
i stared at the histogram colors and my bubble values.
i guessed if the change in w1 is positive, there are yellow histogram bars. if negative then brown. then changed the bubble color to follow that rule. it matched the histogram.
next i found the change in w2 histogram bar height. if positive then cyan. if negative then blue.
----------------------
scan code
Code:
#ttm_wave_crossings_01_scan
#https://usethinkscript.com/threads/chatgpt-bard-other-ai-scripts-which-cant-be-used-in-thinkorswim.13822/page-17#post-148286
#AlwaysLearning
#11/29
#325
#I want to configure a scanner that detects when the TTM_Waves cross the 0 line, if any of the condition is true I want to see that stock in scanner list.
#The conditions are as follows:
# When all waves are below 0,
# and a yellow wave appears, with its length decreasing over the last 2-3 consecutive bars.
# When all waves are above 0,
# and brown wave appears and its length is decreasing over the last 2-3 consecutive bars.
declare lower;
def w1 = ttm_wave().Wave1;
def w2hi = ttm_wave().Wave2High;
def w2lo = ttm_wave().Wave2Low;
#def z0 = ttm_wave().ZeroLine;
def wavesabove = w1 > 0 and w2hi > 0 and w2lo > 0;
def wavesbelow = w1 < 0 and w2hi < 0 and w2lo < 0;
input min_sequential_bars = 2;
#-------------------
def w1chg = w1 - w1[1];
# if w1chg > 0 then yellow. if < 0 then brown(red)
# When all waves are below 0,
# and a yellow wave appears, with its length decreasing over the last 2-3 consecutive bars.
def yellowdecrease = wavesbelow and w1chg > 0 and (sum((w1chg<w1chg[1]), min_sequential_bars) == min_sequential_bars);
# When all waves are above 0,
# and brown wave appears and its length is decreasing over the last 2-3 consecutive bars.
def browndecrease = wavesabove and w1chg < 0 and (sum((w1chg<w1chg[1]), min_sequential_bars) == min_sequential_bars);
#-------------------
def w2chg = (w2hi - w2lo) - (w2hi[1] - w2lo[1]);
# if w2chg > 0 then cyan. if < 0 then blue
#-------------------
plot z = yellowdecrease or browndecrease;
#
------------------
lower test code
Code:
#ttm_wave_crossings_lower
#https://usethinkscript.com/threads/chatgpt-bard-other-ai-scripts-which-cant-be-used-in-thinkorswim.13822/page-17#post-148286
#AlwaysLearning
#11/29
#325
#I want to configure a scanner that detects when the TTM_Waves cross the 0 line, if any of the condition is true I want to see that stock in scanner list.
#The conditions are as follows:
# When all waves are below 0,
# and a yellow wave appears, with its length decreasing over the last 2-3 consecutive bars.
# When all waves are above 0,
# and brown wave appears and its length is decreasing over the last 2-3 consecutive bars.
# ttm_wave
#plot Wave1 = Double.NaN;
#plot Wave2High = Double.NaN;
#plot Wave2Low = Double.NaN;
#plot ZeroLine = Double.NaN;
declare lower;
def w1 = ttm_wave().Wave1;
def w2hi = ttm_wave().Wave2High;
def w2lo = ttm_wave().Wave2Low;
#def z0 = ttm_wave().ZeroLine;
def wavesabove = w1 > 0 and w2hi > 0 and w2lo > 0;
def wavesbelow = w1 < 0 and w2hi < 0 and w2lo < 0;
input min_sequential_bars = 2;
#-------------------
def w1chg = w1 - w1[1];
# if w1chg > 0 then yellow. if < 0 then brown(red)
# When all waves are below 0,
# and a yellow wave appears, with its length decreasing over the last 2-3 consecutive bars.
def yellowdecrease = wavesbelow and w1chg > 0 and (sum((w1chg<w1chg[1]), min_sequential_bars) == min_sequential_bars);
# When all waves are above 0,
# and brown wave appears and its length is decreasing over the last 2-3 consecutive bars.
def browndecrease = wavesabove and w1chg < 0 and (sum((w1chg<w1chg[1]), min_sequential_bars) == min_sequential_bars);
#-------------------
def w2chg = (w2hi - w2lo) - (w2hi[1] - w2lo[1]);
# if w2chg > 0 then cyan. if < 0 then blue
#-------------------
plot z = yellowdecrease or browndecrease;
#-------------------
# outputs
addverticalline(yellowdecrease, "Yellow", color.yellow);
addverticalline(browndecrease, "Brown", color.red);
plot z1 = w1;
plot z2 = w2hi;
plot z3 = w2lo;
plot z4 = 0;
z1.SetDefaultColor(Color.cyan);
z2.SetDefaultColor(Color.green);
z3.SetDefaultColor(Color.red);
z4.SetDefaultColor(Color.white);
z4.setlineweight(2);
addchartbubble(1 or wavesbelow, 1,
# w1 + "\n" +
w1chg
# w2hi + "\n" +
# w2lo + "\n" +
# w2chg
, (if w1chg > 0 then color.yellow else color.red), yes);
#, (if w2chg > 0 then color.cyan else color.blue), yes);
#, color.yellow, yes);
addchartbubble(1 or wavesbelow, 1,
# w1 + "\n" +
# w1chg
# w2hi + "\n" +
# w2lo + "\n" +
w2chg
#, (if w1chg > 0 then color.yellow else color.red), yes);
, (if w2chg > 0 then color.cyan else color.blue), yes);
#, color.yellow, yes);
#