TTM Squeeze Format, Scan, Watchlist, Label For ThinkOrSwim

Hey all,

I'm trying to figure out how to re-create watchlist, specifically how to get the histogram color from the TTM Squeeze indicator to show up in the watchlist box. The other box is showing the color or Stacked EMA indicator. I think if I can get some help how to make the histogram color work, I might be able to figure out the Stacked EMA indicator.

Thanks in advance for any help!

Cheers,

Mike

squeeze.png
 

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

I think this guy's video will get you what you need (?):

Code:
input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
def squeezeHistogram = TTM_Squeeze(price, length, nK, nBB, alertLine).Histogram;
plot hist = if squeezeHistogram>= 0 then
if squeezeHistogram> squeezeHistogram[1] then 2 else 1
else if squeezeHistogram < squeezeHistogram[1] then -2 else -1; assignBackgroundColor(if squeezeHistogram >= 0 then
if squeezeHistogram > squeezeHistogram[1] then color.CYAN else color.BLUE
else if squeezeHistogram < squeezeHistogram[1] then color.RED else color.YELLOW); hist.assignvaluecolor(if squeezeHistogram >= 0 then
if squeezeHistogram > squeezeHistogram[1] then color.CYAN else color.BLUE
else if squeezeHistogram < squeezeHistogram[1] then color.RED else color.YELLOW);
mod edit: added the above source code discussed in the below text
 
Last edited by a moderator:
I'm trying to scan for stocks/options that checks the past 4 TTM Histogram bars to make sure the following conditions are true:
1) TTM_Squeeze().Histogram 3 and 4 are below 0 and histogram 3 is closer to 0 than 4 (so histogram [3] > histogram [4])
2) histogram 1 is greater than histogram 2 and both of them are above 0 line
3) plot if 1 and 2 are true.

I had the code more joined together before but thinkorswim complained that it was too complex (not sure why seems pretty simple conditions). I rewrote it like this which I'm sure is not the best way, could someone look at it and make sure I did it right and perhaps fix whatever I did wrong.

Here is my snipped of code

def negToPos = TTM_Squeeze().Histogram [4] is less than 0 and TTM_Squeeze().Histogram [3] is less than 0;
def bullStart = TTM_Squeeze().Histogram [2] and TTM_Squeeze().Histogram [1] is greater than 0;

def bullRun = TTM_Squeeze().Histogram [1] > TTM_Squeeze().Histogram [2] and TTM_Squeeze().Histogram [3] > TTM_Squeeze().Histogram [4];


plot signal = negToPos and bullStart and bullRun;
 
I'm trying to scan for stocks/options that checks the past 4 TTM Histogram bars to make sure the following conditions are true:
1) TTM_Squeeze().Histogram 3 and 4 are below 0 and histogram 3 is closer to 0 than 4 (so histogram [3] > histogram [4])
2) histogram 1 is greater than histogram 2 and both of them are above 0 line
3) plot if 1 and 2 are true.

I had the code more joined together before but thinkorswim complained that it was too complex (not sure why seems pretty simple conditions). I rewrote it like this which I'm sure is not the best way, could someone look at it and make sure I did it right and perhaps fix whatever I did wrong.

Here is my snipped of code

def negToPos = TTM_Squeeze().Histogram [4] is less than 0 and TTM_Squeeze().Histogram [3] is less than 0;
def bullStart = TTM_Squeeze().Histogram [2] and TTM_Squeeze().Histogram [1] is greater than 0;

def bullRun = TTM_Squeeze().Histogram [1] > TTM_Squeeze().Histogram [2] and TTM_Squeeze().Histogram [3] > TTM_Squeeze().Histogram [4];


plot signal = negToPos and bullStart and bullRun;
bullstart isn't right,
a logic(and) comparison , compared ( > ) to a number

i don't know why you have bullrun formula.

it is more efficient to read external data once and put it in a variable.

here are your 3 rules
Code:
def ttmh = TTM_Squeeze().Histogram;
# rule 1
def one = ( ttmh[3] > ttmh[4] and ttmh[3] < 0 );
# rule 2
def two = ( ttmh[1] > ttmh[2] and ttmh[2] > 0 );
# rule 3
plot three = if ( one and two) then 1 else 0;
 
Hi all,

Does anyone have ThinkOrSwim's source code for the built-in TTM Squeeze indicator? I'm trying to view the script but it says "Source code isn't available." Any help would be greatly appreciated!

Thanks!
 
Hi all,

Does anyone have ThinkOrSwim's source code for the built-in TTM Squeeze indicator? I'm trying to view the script but it says "Source code isn't available." Any help would be greatly appreciated!

Thanks!
The ToS TTM Squeeze source code is copy-protected. We do not post proprietary scripts on this forum.

Here is a list of all the public domain squeeze scripts available on the forum:
https://usethinkscript.com/threads/john-carters-squeeze-pro-replica-questions.8705/#post-80562
 
How do i modify this code to scan for stocks that showing dark bluse?

# First Cyan Histogram Bar
plot scan = if hist > 0 and hist[1] < 0 and hist[2] < hist[1] then 1 else Double.NaN;
 
Last edited by a moderator:
is there a way to print the price candles if a squeeze is active and print a different color if squeeze has fired.
 
is there a way to have the chart change colors based on the TTM squeeze? id like it for my fast charts to catch my eyes. i cant figure out in the script how it determines the colors. thanks
 
is there a way to print the price candles if a squeeze is active and print a different color if squeeze has fired.
add this to the bottom of your script:
Ruby:
AssignPriceColor(
if insqueeze>0 then color.orange else
if fired>0 and fired <8 then color.blue else color.current);
 
Last edited:
There are lots of TTM scanners out there - one that was particularly interesting to me is Yellow to Cyan Histogram Scan. Has anyone coded for that condition and made it available here?
 
There are lots of TTM scanners out there - one that was particularly interesting to me is Yellow to Cyan Histogram Scan. Has anyone coded for that condition and made it available here?
The ToS platform does not make the TTM Squeeze source code is not available or scannable. We have several look-a-likes.
If we use Tomsk's version:
Ruby:
# TTM Squeeze
# original code by TSL 11.13.2019
# modified into a scanner by @MerryDay 8/2022

input price = close;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;

def squeezeHistogram = TTM_Squeeze(price, length, nK, nBB, alertLine).Histogram;
def squeezeStages =
                      if squeezeHistogram >= 0  and squeezeHistogram > squeezeHistogram[1] then 1  #cyan
                 else if squeezeHistogram >= 0  then 2                                             #blue
                 else if squeezeHistogram <  0  and squeezeHistogram < squeezeHistogram[1] then 3  #red
                 else if squeezeHistogram <  0 then 4 else 0;                                      #yellow

# Yellow to Cyan Histogram Scan
# requested by @stcrim
plot scan = squeezeStages[1] == 4 and squeezeStages == 1 ;

How to use this script in the scan hacker:
https://usethinkscript.com/threads/how-to-use-thinkorswim-stock-hacker-scans.284/
 
Alot of times TTM squeeze fires and there is really no movement, other times it's a monstrous move. Wondering how I could filter out bad moves vs obviously the good moves..what indicators are you pairing with TTM squeeze or what data are u analyzing for the huge move thanks
 
Alot of times TTM squeeze fires and there is really no movement, other times it's a monstrous move. Wondering how I could filter out bad moves vs obviously the good moves..what indicators are you pairing with TTM squeeze or what data are u analyzing for the huge move thanks
Research has not found a reliable strategy to filter what moves and what directions.
However, Squeeze is one of the top conversations on this forum, with many traders making the attempts at finding that Holy Grail.

There are hundreds of posts dedicated to the squeeze and attempts to filter out what moves and what directions.:
https://usethinkscript.com/threads/...-label-for-thinkorswim.2751/page-8#post-78885
 
Last edited:
Research has not found a reliable strategy to filter what moves and what directions.
However, Squeeze is one of the top conversations on this forum, with many traders making the attempts at finding that Holy Grail.

There are hundreds of posts dedicated to the squeeze and attempts to filter out what moves and what directions.:
https://usethinkscript.com/threads/...-label-for-thinkorswim.2751/page-8#post-78885
Thanks For the Reply Merry, The Power behind the move is what im looking for but i guess so is everyone else, I might dig into Gamma levels or something to help with this
 
Does anyone knows how to scan for the black dot? low squeeze.
thanks

Code:
#TTM Squeeze Script
def inSqueezelow = TTM_Squeeze().SqueezeAlert == 0;
plot result = sum(insqueezelow,1) == 1;

not sure how to write this.


Code:
declare lower;

def nBB = 2.0;
def Length = 20.0;
def nK_High = 1.0;
def nK_Mid = 1.5;
def nK_Low = 2.0;
def price = close;

def momentum = TTM_Squeeze(price = price, length = length, nk = nk_Mid, nbb = nbb)."Histogram";
plot oscillator = momentum;
def BolKelDelta_Mid = reference BollingerBands("num_dev_up" = nBB, "length" = Length )."upperband" - KeltnerChannels("factor" = nK_Mid, "length" = Length)."Upper_Band";
def BolKelDelta_Low = reference BollingerBands("num_dev_up" = nBB, "length" = Length )."upperband" - KeltnerChannels("factor" = nK_Low, "length" = Length)."Upper_Band";
def BolKelDelta_High = reference BollingerBands("num_dev_up" = nBB, "length" = Length )."upperband" - KeltnerChannels("factor" = nK_High, "length" = Length)."Upper_Band";
oscillator.DefineColor("Up", CreateColor(0, 255, 255));
oscillator.DefineColor("UpDecreasing", CreateColor(0, 0, 255));
oscillator.DefineColor("Down", CreateColor(255, 0, 0));
oscillator.DefineColor("DownDecreasing",  CreateColor(255, 255, 0));
oscillator.AssignValueColor(
if oscillator[1] < oscillator then if oscillator[0] >= 0
then oscillator.Color("Up")
else oscillator.Color("DownDecreasing")
else if oscillator >= 0
then oscillator.Color("UpDecreasing")
else oscillator.Color("Down") );
oscillator.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
oscillator.SetLineWeight(5);

plot squeeze = If(IsNaN(close), Double.NaN, 0);
squeeze.SetPaintingStrategy(PaintingStrategy.POINTS);
squeeze.SetLineWeight(3);
squeeze.DefineColor("NoSqueeze", Color.GREEN);
squeeze.DefineColor("SqueezeLow", Color.black);
squeeze.DefineColor("SqueezeMid", Color.RED);
squeeze.DefineColor("SqueezeHigh", Color.orange);
squeeze.AssignValueColor(
if BolKelDelta_High <= 0 then squeeze.Color("SqueezeHigh") else 
if BolKelDelta_Mid <= 0 then squeeze.Color("SqueezeMid") else 
if BolKelDelta_Low <= 0 then squeeze.Color("SqueezeLow") else squeeze.color("noSqueeze"));
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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