TTM Squeeze Format, Scan, Watchlist, Label For ThinkOrSwim

How is the momentum histogram calculated/derived on the TTM_Squeeze indicator? The source code is hidden in TOS. As in how is it derived mathematically to calculate the bars?

Sorry if this has been answered somewhere, and kindly delete the post if so, but with SO MANY squeeze threads on the forum it's difficult to find a simple answers sometimes.... The TTM Squeeze indicator is obviously a very popular indicator. And who is this Mobius genius guy?
 

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

... I have listed just one below...
So the histogram bars are showing the "momentum" change of the average trading range of the price? In other terms the volatility change of the price? Am I reading that right?

def c = close;
def h = high;
def l = low;
def K = (Highest(h, length) + Lowest(l, length)) / 2 + ExpAverage(c, length);
plot Momo = Inertia(c - K / 2, length);
 
So the histogram bars are showing the "momentum" change of the average trading range of the price? In other terms the volatility change of the price? Am I reading that right?

def c = close;
def h = high;
def l = low;
def K = (Highest(h, length) + Lowest(l, length)) / 2 + ExpAverage(c, length);
plot Momo = Inertia(c - K / 2, length);

Correct... The histogram is momentum and colored dots are the phase/depth of the squeeze...
 
I am looking for a scan for that will give me bars that are currently light blue. I might have missed it, however can you please assist? @wtf_dude @rad14733

The following scan code can be used to identify symbols with the first or second Cyan histogram bar... Simply remove or add the comment "#" to/from the appropriate plot line... The code can be further modified to suit your needs...

Ruby:
def hist = reference TTM_Squeeze.Histogram;

# First Cyan Histogram Bar
plot scan = if hist > 0 and hist[1] < 0 and hist[2] < hist[1] then 1 else Double.NaN;

# Second Cyan Histogram Bar
#plot scan = if hist > 0 and hist[1] > 0 and hist[2] < 0 then 1 else Double.NaN;
 
The following scan code can be used to identify symbols with the first or second Cyan histogram bar... Simply remove or add the comment "#" to/from the appropriate plot line... The code can be further modified to suit your needs...

Ruby:
def hist = reference TTM_Squeeze.Histogram;

# First Cyan Histogram Bar
plot scan = if hist > 0 and hist[1] < 0 and hist[2] < hist[1] then 1 else Double.NaN;

# Second Cyan Histogram Bar
#plot scan = if hist > 0 and hist[1] > 0 and hist[2] < 0 then 1 else Double.NaN;
How would you adjust this code if you wanted to see the histogram before the first Cyan histogram? I will be running it with the following code:
def inSqueeze = TTM_Squeeze().SqueezeAlert == 0;
def result = sum(insqueeze,5) == 5;
 
Was trying to see if it was a way to scan for the momentum increasing like in the video attached:

@Mac Trader Ok... So, as per the video, you would be looking for a Red to Yellow scan because Yellow is the histogram color before Cyan... However, it just finds Red to Yellow, not an actual Buy point... This is a simple scan to configure... It essentially checks to see of the histogram is negative and that the current histogram value is greater than the previous histogram value... You could make it more complex by looking for multiple Red bars followed by multiple Yellow bars as well... The scan doesn't look for the last bar before Cyan as you originally wanted, and can't, as I previously explained... At least not unless we scan for the first or second cyan bar, which are scans that I already have...

Edited to add: All things considered, I didn't find the video to be a good trading strategy example... I do use Yellow bars as entry points but only if combined with a moving average line of the histogram... Otherwise I prefer to wait for Cyan bars... The following image is an example on a SPY 5D 30m chart... The concept is to wait for there to be a gap between the histogram bar and MA line...
 
Last edited by a moderator:
That's a cool idea. I've never seen anyone do that.

That, to me, is one early entry indication... I code most of my histograms with a MA for that reason... The cyan MA color change in the example above tells me when that has happened... Once I find the proper MA length for whatever statistical data the histogram is a measure of it generally works well across all symbols...
 
@BenTen How do I change the background colors for the code you gave in the initial post? Specifically, I would like to change the red background to yellow when the Squeeze is building. Thanks
 
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);
@Doc8315
In the last line of the code change red to yellow.
 
Does anyone know how to program a scan using the TTM Squeeze indicator that will indicate that a squeeze has change blue to red?
 
Does anyone know how to program a scan using the TTM Squeeze indicator that will indicate that a squeeze has change blue to red?

I'm fairly certain it has been posted somewhere but here you go...

Ruby:
def hist = reference TTM_Squeeze.Histogram;

# First Red Histogram Bar
plot scan = if hist < 0 and hist[1] > 0 then 1 else Double.NaN;
 
How would you code for a scan that shows stocks when their TTM Squeeze indicator (I'm referring to the one that comes with ThinkorSwim) is showing upwards momentum? In other words, I am trying to get alerted to a condition where the TTM Squeeze indicator's histogram is currently below the zero line but is approaching it to cross over from below. I would treat the crossover of the zero line as my entry signal, and I'm simply wanting a little room to analyze the stock as its TTM Squeeze indicator approaches that zero line, if that makes sense.

My stab at it would be that I am looking for a stock whose TTM Squeeze indicator histogram has a value less than or equal to -50 one bar ago and is now above that value. But that is a very basic code. I'm sure a much better option is possible!
 
How would you code for a scan that shows stocks when their TTM Squeeze indicator (I'm referring to the one that comes with ThinkorSwim) is showing upwards momentum? In other words, I am trying to get alerted to a condition where the TTM Squeeze indicator's histogram is currently below the zero line but is approaching it to cross over from below. I would treat the crossover of the zero line as my entry signal, and I'm simply wanting a little room to analyze the stock as its TTM Squeeze indicator approaches that zero line, if that makes sense.

My stab at it would be that I am looking for a stock whose TTM Squeeze indicator histogram has a value less than or equal to -50 one bar ago and is now above that value. But that is a very basic code. I'm sure a much better option is possible!

You'd want two rules. Histogram is less than zero. Histogram is greater than -50. So add the study filter twice, once for each of those two rules. And then you can experiment with changing -50 to see if it's better as -30 or -70 or whatever other value is the sweet spot for your needs.
 
Hey what’s up guys I need help Does anyone know how to program a scan using the TTM Squeeze pro indicator that will indicate that a squeeze has 3 dot squeeze that just fire ?
 
Hey what’s up guys I need help Does anyone know how to program a scan using the TTM Squeezepro indicator that will indicate that a squeeze has 3 dot squeeze that just fire ?

This is set to have a minimum of 3 dots (you can change at the input dots) and maxdots of 3, ie; exactly 3 dots, and then a fire bar. You can increase the maxdots at the input screen if you decide more is okay.

I have not tested it in the scanner, but since the picture shows it works on a chart, it should work in the scanner. The curser in the picture is at the only squeeze of 3 dots followed by a fire (non_squeeze) dot

Capture.jpg
Ruby:
input dots    = 3;
input maxdots = 3;
def squeeze_dots = reference TTM_Squeeze().SqueezeAlert;

def dot_count    = if squeeze_dots[1] == 1 and squeeze_dots == 0
                   then 1
                   else if dot_count[1] >= 1 and squeeze_dots == 0
                   then dot_count[1] + 1
                   else 0;
plot fire        = if Between(dot_count[1], dots, maxdots) and squeeze_dots == 1 then 1 else Double.NaN;
fire.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
 
That would be something like the following... But this would catch every instance when downtrend momentum starts to reverse upward...

Edited: Hadn't tested the previous code... Doh...!!!

Ruby:
def hist = reference TTM_Squeeze.Histogram;
plot scan = if hist < 0 and hist > hist[1] and hist[1] < hist[2] then 1 else Double.NaN;

iug7Jta.png


The more comparisons you make, the stronger the downtrend was before the reversal, like this code shows... It compares the current bar to the previous four bars...

Ruby:
def hist = reference TTM_Squeeze.Histogram;
plot scan = if hist < 0 and hist > hist[1] and hist[1] < hist[2] and hist[2] < hist[3] and hist[3] < hist[4] then 1 else Double.NaN;

qbvN6op.png
Hi @rad14733,

I'd appreciate your assistance on a few things...

How do you differentiate between TTM_Squeeze and TTM_SqueezePro in code? I have the later from JC and want to make sure it's being coded for Pro.

1) Is this correct as a scan that looks for a red to yellow histogram with momentum increasing on each yellow candle?
Ruby:
def hist = reference TTM_Squeeze.Histogram;

plot scan = if hist < 0 and hist > hist[1] and hist[1] > hist[2] and hist[2] > hist[3] and hist[3] > hist[4] then 1 else Double.NaN;


2) Also I would like a scan that finds:
5dots in a squeeze (any compression) and just fired...the below code is my attempt and as far as I got, if you can help me complete it, I would very much appreciate it.

Ruby:
def inSqueeze = TTM_Squeeze().SqueezeAlert == 0;

plot result = sum(insqueeze,5) == 5;

Thanks!
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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