TTM Squeeze Format, Scan, Watchlist, Label For ThinkOrSwim

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/
can you do a scanner that shows ttm squeeze histogram turns from dark blue to red ?
opposite this scanner
 

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

Hi guys I will like to see if you can help me with the TTM squeeze dashboard colors as i want use it on the TTM pro version.

What i want if it can be posible is this:

1- When the the ttm fired the first fired bar be cyan color and after that change to green on the second fired.

2-When fired long 1L CYAN color

3-When fired short 1S CYAN color

4-Change color to green after firts fired bar (2L) (2S)

5-Also look for orange squeezes.

Thanks for your help.
 
Last edited by a moderator:
input price = close;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.SIMPLE;
input displace = 0;
def sDev = StDev(data = price[-displace], length = length);
def MidLineBB = MovingAverage(averageType, data = price[-displace], length = length);
def LowerBandBB = MidLineBB + Num_Dev_Dn * sDev;
def UpperBandBB = MidLineBB + Num_Dev_up * sDev;
input factorhigh = 1.0;
input factormid = 1.5;
input factorlow = 2.0;
input trueRangeAverageType = AverageType.SIMPLE;
def shifthigh = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def shiftMid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def shiftlow = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def average = MovingAverage(averageType, price, length);

def Avg = average[-displace];


def UpperBandKCLow = average[-displace] + shiftlow[-displace];
def LowerBandKCLow = average[-displace] - shiftlow[-displace];

def UpperBandKCMid = average[-displace] + shiftMid[-displace];
def LowerBandKCMid = average[-displace] - shiftMid[-displace];

def UpperBandKCHigh = average[-displace] + shifthigh[-displace];
def LowerBandKCHigh = average[-displace] - shifthigh[-displace];

def K = (Highest(high, length) + Lowest(low, length)) /
2 + ExpAverage(close, length);
def momo = Inertia(price - K / 2, length);

def pos = momo>= 0;
def neg = momo< 0;
def up = momo >= momo[1];
def dn = momo < momo[1];


def presqueeze = LowerBandBB > LowerBandKCLow and UpperBandBB < UpperBandKCLow;
def originalSqueeze = LowerBandBB > LowerBandKCMid and UpperBandBB < UpperBandKCMid;
def ExtrSqueeze = LowerBandBB > LowerBandKCHigh and UpperBandBB < UpperBandKCHigh;

plot scan = presqueeze or originalSqueeze or extrSqueeze within 1 bar;


I found this scan here in the forum I will like this scan be modified:

1-Scan 3 dots squeeze + fired
2-This for triple sqz ttm
Thanks
 
can you do a scanner that shows ttm squeeze histogram turns from dark blue to red ?
opposite this scanner

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_YellowToCyan  = squeezeStages[1] == 4 and squeezeStages == 1 ;

# Blue to Red Histogram Scan requested by @fareshersh1
plot scan_BlueToRed  = squeezeStages[1] == 2 and squeezeStages == 3 ;



How to use this script in the scan hacker:
https://usethinkscript.com/threads/how-to-use-thinkorswim-stock-hacker-scans.284/
 
Hi guys I will like to see if you can help me with the TTM squeeze dashboard colors as i want use it on the TTM pro version.

What i want if it can be posible is this:

1- When the the ttm fired the first fired bar be cyan color and after that change to green on the second fired.

2-When fired long 1L CYAN color

3-When fired short 1S CYAN color

4-Change color to green after firts fired bar (2L) (2S)

5-Also look for orange squeezes.

Thanks for your help.

in the future when asking questions, please describe exactly what you want to see and where.
i've read your post and i don't know what you want.
it helps if you imagine other people don't know what you are talking about. that way you have the mindset to explain things thoroughly.


can you clarify some things?

you want a study modified, but didn't provide the code in post#1. is the squeeze pro some study you bought?
posting a scan code doesn't help much as it doesn't include plot colors.

you want dashboard colors..? that doesn't tell us what and where you want to see something? labels on a chart ? columns? lower histogram?

you post a picture of some columns, that appears to show data of what you are asking for ..? so why not use that study? where did the picture come from?

1. when ttm fires , do stuff....
which variable is that? if you want the first bar colored, that implies a collection of bars, which implies a price chart or a histogram, do you want one of those ?

5-Also look for orange squeezes.
don't know how orange fits in to this. can't look for something, if there are no orange plots in the code.
 
Code:
input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
input useChartTime = yes;


 input aggregationPeriod = AggregationPeriod.three_MIN;

def high = high(period = aggregationPeriod);
def low = low(period = aggregationPeriod);
def close = close(period = aggregationPeriod);

def today = GetDay() == GetLastDay();



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; assignPriceColor(if squeezeHistogram >= 0 then
if squeezeHistogram > squeezeHistogram[1] then color.CYAN else color.BLUE
else if squeezeHistogram < squeezeHistogram[1] then color.RED else color.red); 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);

The above is the painted candles to the TTM SQ just if anyone is intrested.
 
As previous post suggested to make custom alert sound in the script as below:

def AlertUp = upCount==1;
def AlertDn = dnCount==1;

Alert(AlertUp, "Cross Up!", Alert.BAR, sound.CustomAlert1);
Alert(AlertDn, "Cross Dn!", Alert.BAR, Sound.Ding);

QUESTION:
Can we add those alert sound script into TOS default script TTM_SQEEZE source code ?
When I try to see its source code under STUDY>EDIT SOURCE>VIEW, it said source code isn't available that I can't add.

Please help if anyone know how to see the source code that I can add or any alternative way to add sound function with script that won't allow us to see its source code?

Thank you!!
 
As previous post suggested to make custom alert sound in the script as below:





QUESTION:
Can we add those alert sound script into TOS default script TTM_SQEEZE source code ?
When I try to see its source code under STUDY>EDIT SOURCE>VIEW, it said source code isn't available that I can't add.

Please help if anyone know how to see the source code that I can add or any alternative way to add sound function with script that won't allow us to see its source code?

Thank you!!
Ruby:
# TTM_Squeeze
# TD Ameritrade IP Company, Inc. (c) 2009-2022
#
# Source code isn't available.

declare lower;

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

plot Histogram = Double.NaN;
plot VolComp = Double.NaN;
plot SqueezeAlert = Double.NaN;

Alert(SqueezeAlert, "SqueezeAlert", Alert.Bar, Sound.ding);
 
I tried the Simpler Trading site for a while and have read John Carter's books (some), I did learn and apply his approach but found no help using any of his trading styles. Ready Aim Fire, Squeeze, new and improved squeeze, yada yada. Even using his ideas just to cull candidates has never done me any good, when I look at the results to see if I would like to trade one I almost always find that the candidate is unsuitable for my trade and I would have been better off using simpler tools to cull my candidates. I stayed a member for 6 months in 2020 or 2021 (can't remember), I was very dissatisfied. Am I wrong? Has anybody here had luck applying his methods?

Also, all here that produce these thinkscript studies and such have my appreciation, I'm too busy learning to trade to want to learn something else. So, thanks to all you coding/thinkscripting folks, old guys that didn't grow up coding appreciate you more than you know.
 
Hi Thinkscript family,

I am looking for Alert on 2min chart if TTM_Squeeze is making lower high for last 2-3 days while price remains same or making new low (positive divergence). Below picture is 2min chart option chart where TTM_Squeeze is making lower high (pink arrows) last 3-4 days while price remains steady or making new low.

I tried few simple things from online to just catch lower high in TTM_Squeeze() but doesn't work out for me. I am willing to try if someone has some snippet of code or idea for me to start with. I really appreciate to read this post and help. Thanks very much.
 

Attachments

  • Screenshot 2023-06-11 at 8.56.46 PM.png
    Screenshot 2023-06-11 at 8.56.46 PM.png
    34.8 KB · Views: 308
I'm looking for a scan that will find stocks where the TTM Squeeze has only 2 or 3 light blue bars. Has anyone created such a scan?
 

Attachments

  • TTMSqueeze.pdf
    12.6 KB · Views: 315
  • TTMSqueeze.jpg
    TTMSqueeze.jpg
    24 KB · Views: 203
Then select whatever you named my study as on the chart tab. Then on the "add conditions" screen it will give you a drop down menu with different options to choose from like squeeze breakout bull, squeeze breakout bear, bull trend change, etc. Select the option you want to scan for and then choose "is true" in the middle column. Good to go
Thank you! works perfectly...and still haven't checked on updates! Still reading page 2 of thread!
 
About two years ago I saw where a thinkscripter had developed labels to set general expectations for squeeze history, but I did not save the script unfortunately. While this label is not a trade trigger type of indicator, it can be used to quickly set expectations for squeeze occurrence frequency and duration. I would like to see if I can get some help building it as follows and others might also like to learn from the process as we go. Here are the steps I would propose:
  1. Start with a label (or what will be the initial showing in the ultimate label) that shows the number of bars in the chart being viewed (i.e. there are X number of bars on this chart).
  2. The next part of the label will say there are X total bars in the TTM squeeze on this chart.
  3. The other parts of the label are then just mathematical derivative parts of the label from these two measures which most interesting are:
    1. What percent of bars are in a squeeze (number of squeezes / total bars as a % ) - this shows how frequently this occurs of all bars
    2. How frequently does a squeeze series initiate - so number of unbroken series (prior bar no squeeze but current bar is squeeze) shows the number of not just the frequency of all bar in squeeze but how frequently a squeeze sequence initiates
    3. Average squeeze duration - shows of all the unbroken series how many bars would be in a squeeze - this is perhaps the most useful as you can characterize and instrument (or at least its period in the chart) to set expectations on how long that might last
    4. Other things are also possible like shortest, longest, longest between squeeze series ...
Once the framework design is made, it is conceivable that any indicator occurrence could be substituted for the squeeze.
Did you ever get this coded? I've been looking for this for a while. Thanks.
 
About two years ago I saw where a thinkscripter had developed labels to set general expectations for squeeze history, but I did not save the script unfortunately. While this label is not a trade trigger type of indicator, it can be used to quickly set expectations for squeeze occurrence frequency and duration. I would like to see if I can get some help building it as follows and others might also like to learn from the process as we go. Here are the steps I would propose:
  1. Start with a label (or what will be the initial showing in the ultimate label) that shows the number of bars in the chart being viewed (i.e. there are X number of bars on this chart).
  2. The next part of the label will say there are X total bars in the TTM squeeze on this chart.
  3. The other parts of the label are then just mathematical derivative parts of the label from these two measures which most interesting are:
    1. What percent of bars are in a squeeze (number of squeezes / total bars as a % ) - this shows how frequently this occurs of all bars
    2. How frequently does a squeeze series initiate - so number of unbroken series (prior bar no squeeze but current bar is squeeze) shows the number of not just the frequency of all bar in squeeze but how frequently a squeeze sequence initiates
    3. Average squeeze duration - shows of all the unbroken series how many bars would be in a squeeze - this is perhaps the most useful as you can characterize and instrument (or at least its period in the chart) to set expectations on how long that might last
    4. Other things are also possible like shortest, longest, longest between squeeze series ...
Once the framework design is made, it is conceivable that any indicator occurrence could be substituted for the squeeze.
Did you ever get this coded? I've been looking for this for a while. Thanks.


show some stat labels, counts, average, based on a test signal.
this has ttm squeeze set up as the signals.
can change these formulas to look at pulse data from another signal.

# ttm_sqz = 0
def signal_start = !ttm_sqz;
# ttm_sqz = 1
def signal_end = ttm_sqz;


if the last bar is in a squeeze, then it calcs a vertical line placement, based on
( average squeeze length - the bars already in the squeeze)

this code shifts the ttm squeeze dots, so they are easier to see.

Code:
# ttm_stats_counts_durations

#https://usethinkscript.com/threads/ttm-squeeze.16135/
#TTM Squeeze
#AlphaOptions  Oct 3, 2019  #1
#About two years ago I saw where a thinkscripter had developed labels to set general expectations for squeeze history, but I did not save the script unfortunately. While this label is not a trade trigger type of indicator, it can be used to quickly set expectations for squeeze occurrence frequency and duration. I would like to see if I can get some help building it as follows and others might also like to learn from the process as we go. Here are the steps I would propose:

#Start with a label (or what will be the initial showing in the ultimate label) that shows the number of bars in the chart being viewed (i.e. there are X number of bars on this chart).

#The next part of the label will say there are X total bars in the TTM squeeze on this chart.
#The other parts of the label are then just mathematical derivative parts of the label from these two measures which most interesting are:
#What percent of bars are in a squeeze (number of squeezes / total bars as a % ) - this shows how frequently this occurs of all bars
#How frequently does a squeeze series initiate - so number of unbroken series (prior bar no squeeze but current bar is squeeze) shows the number of not just the frequency of all bar in squeeze but how frequently a squeeze sequence initiates
#Average squeeze duration - shows of all the unbroken series how many bars would be in a squeeze - this is perhaps the most useful as you can characterize and instrument (or at least its period in the chart) to set expectations on how long that might last

#Other things are also possible like shortest, longest, longest between squeeze series ...
#Once the framework design is made, it is conceivable that any indicator occurrence could be substituted for the squeeze.



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

def na = double.nan;
def bn = barnumber();


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

# ref signal

# TTM_Squeeze
# TD Ameritrade IP Company, Inc. (c) 2009-2023

declare lower;

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

#plot Histogram = Double.NaN;
#plot VolComp = Double.NaN;
#plot SqueezeAlert = Double.NaN;


def ttm_histo = TTM_Squeeze(price, length, nk, nbb, alertline).histogram;
def ttm_volcomp = TTM_Squeeze(price, length, nk, nbb, alertline).volcomp;
def ttm_sqz = TTM_Squeeze(price, length, nk, nbb, alertline).SqueezeAlert;

#  ttm_sqz , 1 , green , no squeeze .  0 , red , squeeze



input show_histo = yes;
plot zttm_histo = if isnan(close) then na else ttm_histo;
zttm_histo.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
zttm_histo.AssignValueColor(
     if ttm_histo > 0 and ttm_histo > ttm_histo[1] then color.cyan
else if ttm_histo > 0 and ttm_histo < ttm_histo[1] then color.blue
else if ttm_histo < 0 and ttm_histo > ttm_histo[1] then color.yellow
else if ttm_histo < 0 and ttm_histo < ttm_histo[1] then color.red
else color.gray);
zttm_histo.setlineweight(3);
zttm_histo.SetHiding(!show_histo);

def offpt = 5;
input offset_points = yes;
def pt = if !offset_points then 0
else if ttm_histo > 0 then -offpt
else if ttm_histo < 0 then offpt
else 0;

input show_sqz_points = yes;
plot zsqz = if isnan(close) then na else pt;
zsqz.SetPaintingStrategy(PaintingStrategy.POINTS);
zsqz.AssignValueColor(if ttm_sqz then color.green else color.red);
zsqz.setlineweight(3);
zsqz.SetHiding(!show_sqz_points);



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

#  ttm_sqz = 0
def signal_start = !ttm_sqz;
#  ttm_sqz = 1
def signal_end = ttm_sqz;

# create a pulse, stays = 1 during signals , until a non signal, then 0
def signal = if bn == 1 then 0
 else if signal_end then 0
 else if signal_start then 1
 else signal[1];



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

# labels,
# 1.  there are X number of bars on this chart
def bar_cnt = highestall(if isnan(close) then 0 else bn);

# 2.  there are X total bars in the TTM squeezes on this chart.
def sig_cnt = if bn == 1 then 0
 else if signal == 1 then sig_cnt[1] + 1
 else sig_cnt[1];

# 3a.  What percent of bars are in a squeeze (number of squeezes / total bars as a % ) - this shows how frequently this occurs of all bars
# count how many squeezes, count the groups of signals
def sig_group_cnt = if bn == 1 then 0
 else if signal_start and signal_end[1] then sig_group_cnt[1] + 1
 else sig_group_cnt[1];

# calc with bn, not bncnt, to use the qty of bars up to the active bar (not all of them. (the last bar will use all the bars)
def sqz_bars_per = round(100 * sig_group_cnt / bn, 1);


# 3b how frequently does a squeeze series initiate - so number of unbroken series (prior bar no squeeze but current bar is squeeze) shows the number of not just the frequency of all bar in squeeze but how frequently a squeeze sequence initiates
# ????
# same as 3a % ?


# 3c.  Average squeeze duration - shows of all the unbroken series how many bars would be in a squeeze
#   this is perhaps the most useful as you can characterize and instrument (or at least its period in the chart) to set expectations on how long that might last
# avg bar len of groups (sqz)
def avg_group_len = round(sig_cnt/sig_group_cnt, 1);


# Other things are also possible like shortest, longest, longest between squeeze series ...

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


# if last bar has a signal (in a sqz)
# then plot a vert line after last bar, to show est last bar of current sqz, based on the avg group (sqz) len
def lastbar_sig = if (bn == bar_cnt and signal_start) then 1 else 0;

def n = 400;
def last_group_bars = if bn == 1 then 0
  else if lastbar_sig then fold e = 0 to n
    with p
    while getvalue(signal_start, e)
    do p + 1
 else lastbar_sig[1];

def future_bars = if isnan(close) then future_bars[1]
 else if last_group_bars > 0 then (rounddown(avg_group_len,0) - last_group_bars)
 else 0;

#def x = !isnan(close[future_bars+1]) and isnan(close[future_bars+0]);
def x = !isnan(getvalue(close, future_bars+1)) and isnan(getvalue(close, future_bars+0));

addverticalline(x, future_bars, color.cyan);


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

input show_labels = yes;
addlabel(show_labels, bar_cnt + " total bars", color.yellow);
addlabel(show_labels, sig_cnt + " signals", color.yellow);
addlabel(show_labels, sig_group_cnt + " groups", color.yellow);
addlabel(show_labels, sqz_bars_per + " % of bars in groups", color.yellow);

#addlabel(show_labels,      , color.yellow);
addlabel(show_labels, avg_group_len + " avg group len", color.yellow);

addlabel(show_labels, last_group_bars + " last group len", color.green);
addlabel(show_labels,  future_bars + " bars remaining", color.green);


#------------------------
# test stuff

addchartbubble(0, 0,
 ttm_histo + " h\n" +
 ttm_volcomp + " v\n" +
 ttm_sqz + "sqz"
, color.yellow, no);


addchartbubble(0, 50,
# ttm_histo + " h\n" +
 ttm_volcomp + " v\n"
# ttm_sqz + "sqz"
, (if ttm_volcomp then color.yellow else color.gray), yes);


input test1_data = no;
addchartbubble(test1_data and !isnan(close), -15,
bn + "\n" +
bar_cnt + " bn\n" +
sig_cnt + " Sbars\n" +
sig_group_cnt + " Sqty\n" +
sqz_bars_per + " %bars\n" +
avg_group_len + " avg len\n" +
last_group_bars + " last"
#future_bars
#x
, color.yellow, no);


input test2_data = no;
addchartbubble(test2_data, -15,
avg_group_len + " avg len\n" +
last_group_bars + " last\n" +
future_bars + " x\n" +
x
, color.yellow, no);

#

TJX 10min 7/24
shows a squeeze on last bar, so it calcs a vertical line placement, based on average squeeze length
KFLzIX3.jpg
 
Last edited by a moderator:
Thanks to all coders here! I use the standard TOS TTM_Squeeze for the charts and wtf_dude's scan from page #2 - I use it on daily only. It works perfectly for me.

Is there a way to filter only results after 8 or more red dots? (something John Carter suggested)

Like this one i.e.:
1690874959059.png


Sorry if I overlooked it here.

Update: Well, I did manage to have 8 red dots in a row and a green one at the end. Can actually do with the condition wizard.
1690896345163.png


Code:
TTM_Squeeze()."SqueezeAlert" from 1 bars ago is false and
TTM_Squeeze()."SqueezeAlert" from 2 bars ago is false and
TTM_Squeeze()."SqueezeAlert" from 3 bars ago is false and
TTM_Squeeze()."SqueezeAlert" from 4 bars ago is false and
TTM_Squeeze()."SqueezeAlert" from 5 bars ago is false and
TTM_Squeeze()."SqueezeAlert" from 6 bars ago is false and
TTM_Squeeze()."SqueezeAlert" from 7 bars ago is false and
TTM_Squeeze()."SqueezeAlert" from 8 bars ago is false and
TTM_Squeeze()."SqueezeAlert" is true
 
Last edited:
Thanks to all coders here! I use the standard TOS TTM_Squeeze for the charts and wtf_dude's scan from page #2 - I use it on daily only. It works perfectly for me.

Is there a way to filter only results after 8 or more red dots? (something John Carter suggested)

Like this one i.e.:


Sorry if I overlooked it here.

Update: Well, I did manage to have 8 red dots in a row and a green one at the end. Can actually do with the condition wizard.


Code:
TTM_Squeeze()."SqueezeAlert" from 1 bars ago is false and
TTM_Squeeze()."SqueezeAlert" from 2 bars ago is false and
TTM_Squeeze()."SqueezeAlert" from 3 bars ago is false and
TTM_Squeeze()."SqueezeAlert" from 4 bars ago is false and
TTM_Squeeze()."SqueezeAlert" from 5 bars ago is false and
TTM_Squeeze()."SqueezeAlert" from 6 bars ago is false and
TTM_Squeeze()."SqueezeAlert" from 7 bars ago is false and
TTM_Squeeze()."SqueezeAlert" from 8 bars ago is false and
TTM_Squeeze()."SqueezeAlert" is true
I am interested to know how this scan has worked out for you since your post. Any changes or improvements? Have you looked into the Squeeze Pro setup with the extra colors/status?
 
For those of you who enjoy using the TTM Squeeze & Momentum indicator, this should be a handy addition to your ThinkorSwim chart setup. The script will add the status of the TTM Squeeze for stocks on your watchlist via a new column. You can select whichever timeframe you would like to scan for TTM squeeze.

Stocks usually break out of consolidations and by having the TTM Squeeze on your watchlist it helps to alert when they do.

Here is what each signal and labels represent:
  • Bright Red: The stock is in Buy zone
  • Dark Red: Market compression is currently in this time period. The number reveals the amount of dots on your TTM Squeeze indicator.
  • Dark Green: The squeeze has fired. The number notes how many dots (up to 5) and whether the squeeze signaled Long or Short.
  • Black: No squeeze on this time frame

View attachment 4687

thinkScript Code

Code:
# Squeeze watchlist column
#   Red Background   - Squeeze is building in the time period - number indicates how many dots
#      w/ white "B"  - Squeeze is building, stock is within "buy zone"
#   Green Background - Squeeze has fired - number indicates how many dots (up to 5 dots)
#                      and whether Squeeze fired L(ong) or S(hort)
#   Black Background - No Squeeze in play

# Original code by Eric Purdy of Simpler Trading 2017
# Modified code by Rich Stratmann to put in background colors and shorten column values
# Updates by dmccuskey
#   - change background colors to aid content scanning
#   - add "B" to time frames which are in the Buy Zone - between 8 & 21 EMA
#   - change "0" to " " <space> so that the content doesn't show when row is highlighted

#ToS Share Code: https://tos.mx/IPrEhH

def sqz = !TTM_Squeeze().SqueezeAlert;
def direction = TTM_Squeeze()>TTM_Squeeze()[1];
def count = if sqz and !sqz[1] then 1 else count[1]+1;
def isFired = if !sqz and sqz[1] then 1 else 0;
def firedCount = if isFired then 1 else firedCount[1]+1;
def firedDirection = if isFired then direction else firedDirection[1];

def sumIsFired = sum(isFired,5);
def isFiredDir = sumIsFired && firedDirection;

# look for close buy zone
def ema8 = reference movAvgExponential(length=8);
def ema21 = reference movAvgExponential(length=21);
def currPrice = close();
def highVal = Max(ema8, ema21);
def lowVal = Min(ema8, ema21);
def inBuyZone = currPrice >= lowVal && currPrice <= highVal;

def sqzBuy = sqz && inBuyZone;
def sqzNoBuy = sqz && !inBuyZone;

addLabel(yes, Concat(if sqzBuy then "B " else "", if sqz then "" + count else if sumIsFired then “” + firedCount + if firedDirection then ” L” else ” S” else “ ”), if sqzBuy then color.white else color.black);

AssignBackgroundColor(if sqzNoBuy then  CreateColor(170, 6, 0) else if sqzBuy then color.red else if sumIsFired then CreateColor(28, 105, 3) else color.black);

Shareable Link

https://tos.mx/uXplYi

Credits:
How can I use this in a scan? I want to scan for tickers that have at least 3 red dots.
 
I would like to have a watchlist column for the Sqz Pro Alert, so i can monitor when the sqz has fired, can u help me with the code, i'm unable to get it to work. Thanks

def sqz = !TTM_SqueezePro().SqueezeAlert;
def direction = ST_SqueezePro()>ST_SqueezePro()[1];
def count = if sqz and !sqz[1] then 1 else count[1]+1;
def fired = if !sqz and sqz[1] then 1 else 0;
def firedCount = if fired then 1 else firedCount[1]+1;
def firedDirection = if fired then direction else firedDirection[1];
addLabel(yes, if sqz then “Squeeze:” + count else if sum(fired,5) then “Fired:” + firedCOunt + if firedDirection then ” Long” else ” Short” else “-”, if sqz then color.red else if sum(fired,5) and firedDirection then color.green else color.orange);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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