TTM_Wave For ThinkorSwim

Dix

New member
In my watchlists I would like to add a column where I can see the values of the TTM Wave for each stock. Can someone assist with the code part? I know how to add columns to my watchlists, etc. Essentially I want to run a pre-market scan to see for example TTM Waves that are greater than +2 or less than -2 for example. I know how to build the scan but also want to add the TTM Wave values to my watchlist for easier sorting. Thanks!
 

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

Thank you very much for your corrections. It will not show Wave B or C when I unselect Wave A.

welcome
i think you are looking at the wrong study.
they have similar names. mine has a _00b on the end.

mine has a drop down to pick one of the wave letters.
yours had 3 inputs.

input wave = { default "A" , "B" , "C" };

settings - wave select
xk8RHVo.jpg
 
Here is a Mobius version
Ruby:
# Mobius ABC Waves
# V01.2015
# Long Wave (C), Medium Wave (B), and Short Wave (A)

declare lower;

def c = close;
plot Value = ExpAverage(ExpAverage(c, 5) -
             ExpAverage(c, 13), 3);
     Value.DefineColor("Blue",Color.CYAN);
     Value.DefineColor("Red", Color.RED);
     Value.AssignValueColor(if Value >= Value[1]
                            then Value.color("Blue")
                            else Value.color("Red"));
     Value.HideTitle();
     Value.HideBubble();
# Wave A
def fastMA1 = ExpAverage(c, 5 * 2);
def slowMA1 = ExpAverage(c, 13 * 2);
def macd1 = fastMA1 - slowMA1;
def signal1 = ExpAverage(macd1, 13 * 2);
plot hist1 = macd1 - signal1;
     hist1.SetPaintingStrategy(PaintingStrategy.Histogram);
     hist1.AssignValueColor(if hist1 < 0 and hist1 < hist1[1]
                            then color.dark_red
                            else if hist1 < 0 and
                                    hist1 > hist1[1]
                                 then color.yellow
                            else if hist1 > 0 and
                                    hist1 > hist1[1]
                                 then color.yellow
                            else color.dark_red);
    hist1.HideBubble();
    hist1.HideTitle();
def fastMA2 = ExpAverage(c, 5 * 2);
def slowMA2 = ExpAverage(c, 13 * 3);
def macd2 = fastMA2 - slowMA2;
def signal2 = ExpAverage(macd2, 13 * 3);
plot hist2 = macd2 - signal2;
     hist2.SetPaintingStrategy(PaintingStrategy.Histogram);
     hist2.AssignValueColor(if hist2 < 0 and hist2 < hist2[1]
                            then color.dark_red
                            else if hist2 < 0 and
                                    hist2 > hist2[1]
                                 then color.yellow
                            else if hist2 > 0 and
                                    hist2 > hist2[1]
                                 then color.yellow
                            else color.dark_red);
    hist2.HideBubble();
    hist2.HideTitle();
# Wave B
def fastMA3 = ExpAverage(c, 5 * 2);
def slowMA3 = ExpAverage(c, 13 * 5);
def macd3 = fastMA3 - slowMA3;
def signal3 = ExpAverage(macd3, 13 * 5);
plot hist3 = macd3 - signal3;
     hist3.SetPaintingStrategy(PaintingStrategy.Histogram);
     hist3.AssignValueColor(if hist2 < 0
                            then color.blue
                            else color.cyan);
    hist3.HideBubble();
    hist3.HideTitle();
def fastMA4 = ExpAverage(c, 5 * 2);
def slowMA4 = ExpAverage(c, 13 * 10);
def macd4 = fastMA4 - slowMA4;
def signal4 = ExpAverage(macd4, 13 * 10);
plot hist4 = macd4 - signal4;
     hist4.SetPaintingStrategy(PaintingStrategy.Histogram);
     hist4.AssignValueColor(if hist2 < 0
                            then color.blue
                            else color.cyan);
    hist4.HideBubble();
    hist4.HideTitle();
# Wave C
def fastMA5 = ExpAverage(c, 5 * 2);
def slowMA5 = ExpAverage(c, 13 * 20);
def macd5 = fastMA5 - slowMA5;
def signal5 = ExpAverage(macd5, 13 * 20);
plot hist5 = macd5 - signal5;
     hist5.SetPaintingStrategy(PaintingStrategy.Histogram);
     hist5.AssignValueColor(if hist2 < 0
                            then color.blue
                            else color.cyan);
    hist5.HideBubble();
    hist5.HideTitle();
def fastMA6 = ExpAverage(c, 5 * 2);
def slowMA6 = ExpAverage(c, 13 * 30);
plot macd6 = fastMA6 - slowMA6;
     macd6.SetPaintingStrategy(PaintingStrategy.Histogram);
     macd6.AssignValueColor(if hist2 < 0
                            then color.blue
                            else color.cyan);
    macd6.HideBubble();
    macd6.HideTitle();
plot zero = if isNaN(c) then double.nan else 0;
     zero.SetDefaultColor(Color.yellow);
     zero.HideBubble();
     zero.HideTitle();
# End Code Mobius ABC Waves
 
I really liked the idea of creating more screen real estate by making the ABC Wave confluence a simple line on the chart. I created the Bearish condition to plot as well. This is my first attempt at coding anything, and for some reason it wouldn't work as one ThinkScript so my work-around was to create two separate studies (one bear, one bull) and then make the black lines (referred to as Neutral Waves) fully transparent by creating a Global Colors setting that can be manipulated. I then plotted it to the Squeeze indicator vs. the actual chart.
Code:
# Draw Vertical Signal when All Histogram Waves are above the Zero Line

DefineGlobalColor("Bullish Waves", Color.DARK_GREEN);
DefineGlobalColor("Neutral Waves", Color.Black);

AddVerticalLine(close, ”” , (if TTM_Wave()."Wave1" >0 and TTM_Wave()."Wave2high" >0 and  TTM_Wave()."Wave2low" >0 then GlobalColor("Bullish Waves") else GlobalColor("Neutral Waves")));

Code:
# Draw Vertical Signal when All Histogram Waves are below the Zero Line

DefineGlobalColor("Bearish Waves", Color.Dark_RED);
DefineGlobalColor("Neutral Waves", Color.Black);

AddVerticalLine(close, ”” , (if TTM_Wave()."Wave1" <0 and TTM_Wave()."Wave2high" <0 and  TTM_Wave()."Wave2low" <0 then GlobalColor("Bearish Waves") else GlobalColor("Neutral Waves")));
Photos for Reference
Notice lines on Squeeze Indicator:
TTM-Wave-Lines.png


Settings (make "Neutral Waves" fully transparent on both studies):
TTM-Wave-Lines-Settings.png
 
Last edited by a moderator:
Good afternoon Members!
Seeking help with script for TOS scanner. Hopefully simple but still above what I'm able to do.

I utilize the TTM Wave (1) or A on my chart. Red and Yellow Histogram.
Looking for scanner code that identifies stocks where the histogram bar is changing today from red to yellow or trending better than the previous day.

Thanks!
 
Good afternoon Members!
Seeking help with script for TOS scanner. Hopefully simple but still above what I'm able to do.

I utilize the TTM Wave (1) or A on my chart. Red and Yellow Histogram.
Looking for scanner code that identifies stocks where the histogram bar is changing today from red to yellow or trending better than the previous day.

Thanks!
plot YellowHistogram = TTM_Wave()."Wave1" is greater than TTM_Wave()."Wave1" from 1 bars ago;
plot RedHistogram = TTM_Wave()."Wave1" is less than TTM_Wave()."Wave1" from 1 bars ago;
 
Last edited:
Hi guys,
I am trying to create a ttm wave watchlist, with A,B and C above zero for going long or below zero for going short. with colored background. here is what I have so far:

def waveA = TTM_Wave().Wave1;
def abovezero = waveA > 0;
def belowzero = waveA < 0;
AssignBackgroundColor(
if abovezero and abovezero[1] then Color.GREEN
else if belowzero and !belowzero[1] then Color.RED
else color.black );
plot scan = abovezero && belowzero;


im trying to add below zero as well but, can't figure out how to do it. I would also want to add if its long or short. For example, it C wave is above zero it would be green and say long.

the watchlist is from Dr John Carter lecture timestamp 17:24.The Squeeze" by John F. Carter - As Seen on TradeStation TradingApp Store Showcase

Thanks
 
Last edited:
welcome
i think you are looking at the wrong study.
they have similar names. mine has a _00b on the end.

mine has a drop down to pick one of the wave letters.
yours had 3 inputs.

input wave = { default "A" , "B" , "C" };

settings - wave select
xk8RHVo.jpg
Hi,
is it possible to make this into a watchlist?
 
you will need to come up formulas for waves A, B, C before anything can be done.

ttm_wave has 3 plots
plot Wave1 =
plot Wave2High =
plot Wave2Low =

none of them are A , B, C
 
Last edited by a moderator:
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
 
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);

#-------------------------
#
 
@halcyonguy custom column, need to know when ttmwave1, ttmwave2 high or ttmwave2 low above zero line, the counts +1,2,3 so on the same when crossing below zero line counts -1,-2,-3, and so on
 
Last edited by a moderator:
#
# TD Ameritrade IP Company, Inc. (c) 2010-2023
#
# Source code isn't available.

declare lower;

plot Wave1 = Double.NaN;
plot Wave2High = Double.NaN;
plot Wave2Low = Double.NaN;
plot ZeroLine = Double.NaN;



curious if this can be made into mtf?
 
#
# TD Ameritrade IP Company, Inc. (c) 2010-2023
#
# Source code isn't available.

declare lower;

plot Wave1 = Double.NaN;
plot Wave2High = Double.NaN;
plot Wave2Low = Double.NaN;
plot ZeroLine = Double.NaN;



curious if this can be made into mtf?
The script is proprietary. Without the script, it is not possible to modify the script.

There are many other non-proprietary scripts in this thread that you could adapt.
Here is how to create an MTF:
https://usethinkscript.com/threads/converting-indicator-to-multi-timeframe-mtf-in-thinkorswim.8050/
 
Last edited:
Here is a Mobius version
Ruby:
# Mobius ABC Waves
# V01.2015
# Long Wave (C), Medium Wave (B), and Short Wave (A)

declare lower;

def c = close;
plot Value = ExpAverage(ExpAverage(c, 5) -
             ExpAverage(c, 13), 3);
     Value.DefineColor("Blue",Color.CYAN);
     Value.DefineColor("Red", Color.RED);
     Value.AssignValueColor(if Value >= Value[1]
                            then Value.color("Blue")
                            else Value.color("Red"));
     Value.HideTitle();
     Value.HideBubble();
# Wave A
def fastMA1 = ExpAverage(c, 5 * 2);
def slowMA1 = ExpAverage(c, 13 * 2);
def macd1 = fastMA1 - slowMA1;
def signal1 = ExpAverage(macd1, 13 * 2);
plot hist1 = macd1 - signal1;
     hist1.SetPaintingStrategy(PaintingStrategy.Histogram);
     hist1.AssignValueColor(if hist1 < 0 and hist1 < hist1[1]
                            then color.dark_red
                            else if hist1 < 0 and
                                    hist1 > hist1[1]
                                 then color.yellow
                            else if hist1 > 0 and
                                    hist1 > hist1[1]
                                 then color.yellow
                            else color.dark_red);
    hist1.HideBubble();
    hist1.HideTitle();
def fastMA2 = ExpAverage(c, 5 * 2);
def slowMA2 = ExpAverage(c, 13 * 3);
def macd2 = fastMA2 - slowMA2;
def signal2 = ExpAverage(macd2, 13 * 3);
plot hist2 = macd2 - signal2;
     hist2.SetPaintingStrategy(PaintingStrategy.Histogram);
     hist2.AssignValueColor(if hist2 < 0 and hist2 < hist2[1]
                            then color.dark_red
                            else if hist2 < 0 and
                                    hist2 > hist2[1]
                                 then color.yellow
                            else if hist2 > 0 and
                                    hist2 > hist2[1]
                                 then color.yellow
                            else color.dark_red);
    hist2.HideBubble();
    hist2.HideTitle();
# Wave B
def fastMA3 = ExpAverage(c, 5 * 2);
def slowMA3 = ExpAverage(c, 13 * 5);
def macd3 = fastMA3 - slowMA3;
def signal3 = ExpAverage(macd3, 13 * 5);
plot hist3 = macd3 - signal3;
     hist3.SetPaintingStrategy(PaintingStrategy.Histogram);
     hist3.AssignValueColor(if hist2 < 0
                            then color.blue
                            else color.cyan);
    hist3.HideBubble();
    hist3.HideTitle();
def fastMA4 = ExpAverage(c, 5 * 2);
def slowMA4 = ExpAverage(c, 13 * 10);
def macd4 = fastMA4 - slowMA4;
def signal4 = ExpAverage(macd4, 13 * 10);
plot hist4 = macd4 - signal4;
     hist4.SetPaintingStrategy(PaintingStrategy.Histogram);
     hist4.AssignValueColor(if hist2 < 0
                            then color.blue
                            else color.cyan);
    hist4.HideBubble();
    hist4.HideTitle();
# Wave C
def fastMA5 = ExpAverage(c, 5 * 2);
def slowMA5 = ExpAverage(c, 13 * 20);
def macd5 = fastMA5 - slowMA5;
def signal5 = ExpAverage(macd5, 13 * 20);
plot hist5 = macd5 - signal5;
     hist5.SetPaintingStrategy(PaintingStrategy.Histogram);
     hist5.AssignValueColor(if hist2 < 0
                            then color.blue
                            else color.cyan);
    hist5.HideBubble();
    hist5.HideTitle();
def fastMA6 = ExpAverage(c, 5 * 2);
def slowMA6 = ExpAverage(c, 13 * 30);
plot macd6 = fastMA6 - slowMA6;
     macd6.SetPaintingStrategy(PaintingStrategy.Histogram);
     macd6.AssignValueColor(if hist2 < 0
                            then color.blue
                            else color.cyan);
    macd6.HideBubble();
    macd6.HideTitle();
plot zero = if isNaN(c) then double.nan else 0;
     zero.SetDefaultColor(Color.yellow);
     zero.HideBubble();
     zero.HideTitle();
# End Code Mobius ABC Waves
Can someone please explain how to interpret this? It looks like the yellow/red histogram is Wave A (the shortest term wave). Not clear to me if the blue/cyan histogram is Wave B or C. And it looks like the plotted line is none of the waves.

What I ended up doing is adding TOS default TTM_Wave script to the chart 3 times as lower panels so I could have each of wave A, B, and C plotted separately. According to some site I found, for:
Wave A: turn off plots for Wave2High and Wave2Low (Wave1 is Wave A)
Wave B: turn off plots for Wave1 and Wave2Low (Wave2High is Wave B)
Wave C: turn off plots for Wave1 and Wave2High (Wave2Low is Wave C)

Does anyone know if this is correct regarding TOS default TTM_Wave script? Since it's a TOS built-in script, the code is not available for viewing.
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
304 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