Repaints Multiple Time Frame (MTF) Squeeze Indicator for ThinkorSwim

Repaints
***For the record - I actually subscribe to John Carter's options room & alert service so I see their charts as compared to mine every day. That being said - I'd like to think I have a decent feel for the accuracy of my "knock-off" indicators. I know the squeeze is spot on. That's the key one to get right anyways. The histogram doesn't always mimic his but it is sort-of secondary in the decision-making process so not a big deal IMO. Either way - if someone can figure out how the original TTM_Squeeze histogram functions and can replicate that....I'd be very interested :)!
 
It looks like I cutoff some of the code. paste this at the bottom of my last post.
It's a lower study. The colors represent the dots on the squeeze.

My hope is to make a label - just like yours - that tells me what color dot the squeeze is at for a given timeframe.
(i.e. - if the 5 minute squeeze is a black dot, the 5M label would be black)

Code:
def midSqueeze = BolKelDelta_Mid <= 0;
def triggerMid = if sum(midSqueeze,triggerBars) == triggerBars and !midSqueeze[triggerBars] then 1 else 0;

plot signalMidLong = if triggerMid and ((LongShortDefinition == LongShortDefinition.HistAboveBelowZero and  oscillator > 0) or (LongShortDefinition == LongShortDefinition.HistRisingFalling and  oscillator > oscillator[1]) or (LongShortDefinition == LongShortDefinition.HistRisingFromBelowFallingFromAbove and oscillator > oscillator[1] and oscillator < 0 )) then low-signalOffset else double.nan;

signalMidLong.SetPaintingStrategy(paintingStrategy.ARROW_UP);
signalMidLong.setDefaultColor(color.red);
signalMidLong.setLineWeight(5);

plot signalMidShort = if triggerMid and ((LongShortDefinition == LongShortDefinition.HistAboveBelowZero and  oscillator <= 0) or (LongShortDefinition == LongShortDefinition.HistRisingFalling and  oscillator < oscillator[1]) or (LongShortDefinition == LongShortDefinition.HistRisingFromBelowFallingFromAbove and oscillator < oscillator[1] and oscillator > 0 )) then high+signalOffset else double.nan;

signalMidShort.SetPaintingStrategy(paintingStrategy.ARROW_Down);
signalMidShort.setDefaultColor(color.red);
signalMidShort.setLineWeight(5);

def highSqueeze = BolKelDelta_High <= 0;
def triggerHigh = if sum(highSqueeze,triggerBars) == triggerBars and !highSqueeze[triggerBars] then 1 else 0;

plot signalHighLong = if triggerHigh and ((LongShortDefinition == LongShortDefinition.HistAboveBelowZero and  oscillator > 0) or (LongShortDefinition == LongShortDefinition.HistRisingFalling and  oscillator > oscillator[1]) or (LongShortDefinition == LongShortDefinition.HistRisingFromBelowFallingFromAbove and oscillator > oscillator[1] and oscillator < 0 )) then low-signalOffset else double.nan;

signalHighLong.SetPaintingStrategy(paintingStrategy.ARROW_UP);
signalHighLong.setDefaultColor(color.dark_orange);
signalHighLong.setLineWeight(5);

plot signalHighShort = if triggerHigh and ((LongShortDefinition == LongShortDefinition.HistAboveBelowZero and  oscillator <= 0) or (LongShortDefinition == LongShortDefinition.HistRisingFalling and  oscillator < oscillator[1]) or (LongShortDefinition == LongShortDefinition.HistRisingFromBelowFallingFromAbove and oscillator < oscillator[1] and oscillator > 0 )) then high+signalOffset else double.nan;

signalHighShort.SetPaintingStrategy(paintingStrategy.ARROW_Down);
signalHighShort.setDefaultColor(color.dark_orange);
signalHighShort.setLineWeight(5);


So are you looking for a lower timeframe study or an upper timeframe study?
 
Yep I believe my post accomplishes this. You can add the shared grid from my post to get the code...I'm too lazy to post it in here but I don't mind if someone else does. John Carter's version requires you to add multiple instances of the label for each time frame you want, for both the squeeze and the histogram. My solution functions the same way. The pic in my post does not show labels for the 1m, 2m, 3m or 4m as I find those too short to be reliable
 
Last edited:
All - I've been working on building a comparable setup to John Carter's squeeze pro labels + histogram labels.

I was able to modify code I found here to accomplish the "squeeze pro" portion of this. Unfortunately, it is tough to find a histogram that matches Carter's. Mobius' code has a good histogram but I find it not nearly as smooth as John Carter's. However, I found the "Awesome Oscillator" in TOS to be very close to the TTM_Squeeze histogram when you modify the 2 period lengths in the code to be 9 & 21 instead of 5 & 34. I took this logic and built an "MTF histogram label" that sits just underneath the squeeze label...similar to JC's. I've watched several of his videos and confirmed that the squeeze portion of my code works verbatim to his. The histogram is not exact but it is "damn close."

Pic of my setup here:

Screenshot-2020-05-15-22-33-27.png


Here is a link to my shared grid, containing the histogram & squeeze labels: https://tos.mx/xkLakTN

Color legend for those unfamiliar:
  • Top row are the squeezes - Gray = low squeeze, Red = med squeeze (same as the original TTM_Squeeze indicator) and Yellow = high squeeze (this is the tightest squeeze).
  • Bottom row contains histograms: Cyan = increasing positive momentum, Blue = waning positive momentum, Red = increasing negative momentum & Yellow = waning negative momentum.

Let me know your thoughts...
This looks just like the histogram I saw on the newest JC multi squeeze pro and histogram. However, when I try to use your link I get an error message. I'm not sure if I'm doing something wrong.
 
This looks just like the histogram I saw on the newest JC multi squeeze pro and histogram. However, when I try to use your link I get an error message. I'm not sure if I'm doing something wrong.
@LG40 - did you import it into Thinkorswim? You will have to hit setup in the top right corner of TOS, select "open shared item", then paste this link in the box: https://tos.mx/xkLakTN.

Let me know if you still have issues

Cheers!
 
@maverick0987 This is incredible, thank you! I have a few questions. With regards to the squeeze labels (Monthly, Weekly, Daily, Hourly ... Minute), is there any way to display all the labels regardless of the timeframe? For instance with a 6M:1D timeframe, it only displays (M, W, 4D, 3D, 2D, and D). The timeframe would need to be adjusted to the 1 minute to be able to see lower labels. My second question involves the histogram labels, is there any other way to get a 2nd row of labels instead of using the "hack" of adding blank labels?
 
@maverick0987 This is incredible, thank you! I have a few questions. With regards to the squeeze labels (Monthly, Weekly, Daily, Hourly ... Minute), is there any way to display all the labels regardless of the timeframe? For instance with a 6M:1D timeframe, it only displays (M, W, 4D, 3D, 2D, and D). The timeframe would need to be adjusted to the 1 minute to be able to see lower labels. My second question involves the histogram labels, is there any other way to get a 2nd row of labels instead of using the "hack" of adding blank labels?
@coffeewin Unfortunately the timeframe issue is a limitation of TOS. You can only view aggregations that are greater than the chart you are on. So a 1m chart can aggregate all timeframes. A weekly chart can only aggregate weekly, monthly, quarterly and greater. I use the grid setup with the 1m chart on the right and change the timeframe on the left when I see a signal from the labels I want to investigate.

I've seen JC's "edit studies" popup during a live session and he has an instance of the label for each timeframe and a blanklabel to get the histogram on the second line. My "blanklabel" is pretty shoddy from a coding standpoint - I'm sure there is someone on here that can make it start on a new line a lot cleaner. For the record although I have some previous programming experience, I literally learned Thinkscript syntax Friday night while trying to build this tool so my experience is very limited. There invariably may be an easier way to do all of this.
 
@coffeewin Unfortunately the timeframe issue is a limitation of TOS. You can only view aggregations that are greater than the chart you are on. So a 1m chart can aggregate all timeframes. A weekly chart can only aggregate weekly, monthly, quarterly and greater. I use the grid setup with the 1m chart on the right and change the timeframe on the left when I see a signal from the labels I want to investigate.

I've seen JC's "edit studies" popup during a live session and he has an instance of the label for each timeframe and a blanklabel to get the histogram on the second line. My "blanklabel" is pretty shoddy from a coding standpoint - I'm sure there is someone on here that can make it start on a new line a lot cleaner. For the record although I have some previous programming experience, I literally learned Thinkscript syntax Friday night while trying to build this tool so my experience is very limited. There invariably may be an easier way to do all of this.
I see that makes sense. After browsing around, JC seems to confirm what you have said in this article: How to Configure a Multi-Time Frame label study on TOS. They don't show exactly how they define the blank labels but it seems like it's the same as how you do it. I've also been looking around to see if it's possible to have a transparent/opaque label but looking at the CreateColor documentation, it seems impossible to add an alpha value since the function only takes RGB instead of RGBA. To get around this limitation, the best alternative I've found is to make the color of the label the same as the chart background to make it seem invisible. I did this by screenshotting the chart, using a color picker to obtain the RGB color values, and then setting the label color to this RGB value. The other method was not even using blank labels by resizing the window width to just the right size so that the interval and histogram labels are on two different rows. This is probably how JC does it as well since in all his videos, the double row is always in a small window.
 
Can you explain a little about the two studies on the right side of your grid, the Theo Trade Cumulative QuanTicks, and the comparison of CANDLE and $ADSPD?
 
Thanks @maverick0987

Looks like there is an issue(if I am not wrong) in the TTM squeeze label colors - I dont see black and Orange in the label code.. Can you please check.
 
Last edited:
Thanks @maverick0987

Looks like there is an issue(if I am not wrong) in the TTM squeeze label colors - I dont see black and Orange in the label code.. Can you please check.
I used gray and yellow instead of black and orange b/c the background of my chart is black. I chose colors that work better for my eyes. I believe John uses the same colors
 
Can you explain a little about the two studies on the right side of your grid, the Theo Trade Cumulative QuanTicks, and the comparison of CANDLE and $ADSPD?
I use ticks to avoid shorting on a day when buying pressure is high and vice-versa. You can google tick charts & Corey Rosenbloom to learn more about this. $ADSPD is Advance-Decline, which is just another market internal indicator. The Quanticks is just showing cumulative activity in the ticks from the cash open.
 
Do you have the link to the $ADSPD Advance-Decline?
All I did for that is goto the "Comparison" indicator already in TOS and move it from the upper to the lower portion of the chart (it will default to upper). Then type in $ADSPD as the ticker within the indicator parameters. Voila!
 
Hey Maverick thanks for your work. I have a question for you and anyone else using Squeezes. They definitely work as far as predicting breakouts but I'm still having a hell of a time figuring out which direction the breakout will go. Any insights?
 
Not sure about the blank spots but this is my version of the squeeze with MORE DOTS!
There are 6 aggregations, you can pick the "vote" for the topline to show is "x" of 6 are in line with each other.
GnPPmSd.png

Code:
declare lower;
input AP1 = AggregationPeriod.DAY;
input AP2 = AggregationPeriod.TWO_DAYS;
input AP3 = AggregationPeriod.THREE_DAYS;
input AP4 = AggregationPeriod.FOUR_DAYS;
input AP5 = AggregationPeriod.WEEK;
input AP6 = AggregationPeriod.MONTH;
input vote = 3;

def price1 = CLOSE(period = AP1);
def price2 = CLOSE(period = AP2);
def price3 = CLOSE(period = AP3);
def price4 = CLOSE(period = AP4);
def price5 = CLOSE(period = AP5);
def price6 = CLOSE(period = AP6);
def length = 20;
def nK = 1.5;
def nBB = 2.0;
def alertLine = 1.0;
def Sqz_Length = 3;

def squeezeDots1 = TTM_Squeeze(price1, length, nK, nBB, alertLine).SqueezeAlert;
def squeezeDots2 = TTM_Squeeze(price2, length, nK, nBB, alertLine).SqueezeAlert;
def squeezeDots3 = TTM_Squeeze(price3, length, nK, nBB, alertLine).SqueezeAlert;
def squeezeDots4 = TTM_Squeeze(price4, length, nK, nBB, alertLine).SqueezeAlert;
def squeezeDots5 = TTM_Squeeze(price5, length, nK, nBB, alertLine).SqueezeAlert;
def squeezeDots6 = TTM_Squeeze(price6, length, nK, nBB, alertLine).SqueezeAlert;



def Top_Plot = (squeezeDots1 + squeezeDots2 + squeezeDots3 + squeezeDots4 +  squeezeDots5 +squeezeDots6) >= Vote;

plot MTF_Sqz = 7;
MTF_Sqz.SetPaintingStrategy(PaintingStrategy.POINTS);
MTF_Sqz.AssignValueColor(if Top_Plot == 1 then Color.BLACK else Color.DARK_RED);
MTF_Sqz.SetLineWeight(5);

plot Sqeezy1 = if squeezeDots1 == 1 then squeezeDots1 + 5 else 6;
plot Sqeezy2 = if squeezeDots2 == 1 then squeezeDots2 + 4 else 5;
plot Sqeezy3 = if squeezeDots3 == 1 then squeezeDots3 + 3 else 4;
plot Sqeezy4 = if squeezeDots4 == 1 then squeezeDots4 + 2 else 3;
plot Sqeezy5 = if squeezeDots5 == 1 then squeezeDots5 + 1 else 2;
plot Sqeezy6 = if squeezeDots6 == 1 then squeezeDots6 else 1;

Sqeezy1.SetPaintingStrategy(PaintingStrategy.POINTS);
Sqeezy1.AssignValueColor(if squeezeDots1 == 1 then Color.DARK_GREEN else Color.DARK_RED);
Sqeezy1.SetLineWeight(3);
Sqeezy2.SetPaintingStrategy(PaintingStrategy.POINTS);
Sqeezy2.AssignValueColor(if squeezeDots2 == 1 then Color.DARK_GREEN else Color.DARK_RED);
Sqeezy2.SetLineWeight(3);
Sqeezy3.SetPaintingStrategy(PaintingStrategy.POINTS);
Sqeezy3.AssignValueColor(if squeezeDots3 == 1 then Color.DARK_GREEN else Color.DARK_RED);
Sqeezy3.SetLineWeight(3);
Sqeezy4.SetPaintingStrategy(PaintingStrategy.POINTS);
Sqeezy4.AssignValueColor(if squeezeDots5 == 1 then Color.DARK_GREEN else Color.DARK_RED);
Sqeezy4.SetLineWeight(3);
Sqeezy5.SetPaintingStrategy(PaintingStrategy.POINTS);
Sqeezy5.AssignValueColor(if squeezeDots5 == 1 then Color.DARK_GREEN else Color.DARK_RED);
Sqeezy5.SetLineWeight(3);
Sqeezy6.SetPaintingStrategy(PaintingStrategy.POINTS);
Sqeezy6.AssignValueColor(if squeezeDots6 == 1 then Color.DARK_GREEN else  Color.DARK_RED);
Sqeezy6.SetLineWeight(3);
Not sure about the blank spots but this is my version of the squeeze with MORE DOTS!
There are 6 aggregations, you can pick the "vote" for the topline to show is "x" of 6 are in line with each other.
GnPPmSd.png

Code:
declare lower;
input AP1 = AggregationPeriod.DAY;
input AP2 = AggregationPeriod.TWO_DAYS;
input AP3 = AggregationPeriod.THREE_DAYS;
input AP4 = AggregationPeriod.FOUR_DAYS;
input AP5 = AggregationPeriod.WEEK;
input AP6 = AggregationPeriod.MONTH;
input vote = 3;

def price1 = CLOSE(period = AP1);
def price2 = CLOSE(period = AP2);
def price3 = CLOSE(period = AP3);
def price4 = CLOSE(period = AP4);
def price5 = CLOSE(period = AP5);
def price6 = CLOSE(period = AP6);
def length = 20;
def nK = 1.5;
def nBB = 2.0;
def alertLine = 1.0;
def Sqz_Length = 3;

def squeezeDots1 = TTM_Squeeze(price1, length, nK, nBB, alertLine).SqueezeAlert;
def squeezeDots2 = TTM_Squeeze(price2, length, nK, nBB, alertLine).SqueezeAlert;
def squeezeDots3 = TTM_Squeeze(price3, length, nK, nBB, alertLine).SqueezeAlert;
def squeezeDots4 = TTM_Squeeze(price4, length, nK, nBB, alertLine).SqueezeAlert;
def squeezeDots5 = TTM_Squeeze(price5, length, nK, nBB, alertLine).SqueezeAlert;
def squeezeDots6 = TTM_Squeeze(price6, length, nK, nBB, alertLine).SqueezeAlert;



def Top_Plot = (squeezeDots1 + squeezeDots2 + squeezeDots3 + squeezeDots4 +  squeezeDots5 +squeezeDots6) >= Vote;

plot MTF_Sqz = 7;
MTF_Sqz.SetPaintingStrategy(PaintingStrategy.POINTS);
MTF_Sqz.AssignValueColor(if Top_Plot == 1 then Color.BLACK else Color.DARK_RED);
MTF_Sqz.SetLineWeight(5);

plot Sqeezy1 = if squeezeDots1 == 1 then squeezeDots1 + 5 else 6;
plot Sqeezy2 = if squeezeDots2 == 1 then squeezeDots2 + 4 else 5;
plot Sqeezy3 = if squeezeDots3 == 1 then squeezeDots3 + 3 else 4;
plot Sqeezy4 = if squeezeDots4 == 1 then squeezeDots4 + 2 else 3;
plot Sqeezy5 = if squeezeDots5 == 1 then squeezeDots5 + 1 else 2;
plot Sqeezy6 = if squeezeDots6 == 1 then squeezeDots6 else 1;

Sqeezy1.SetPaintingStrategy(PaintingStrategy.POINTS);
Sqeezy1.AssignValueColor(if squeezeDots1 == 1 then Color.DARK_GREEN else Color.DARK_RED);
Sqeezy1.SetLineWeight(3);
Sqeezy2.SetPaintingStrategy(PaintingStrategy.POINTS);
Sqeezy2.AssignValueColor(if squeezeDots2 == 1 then Color.DARK_GREEN else Color.DARK_RED);
Sqeezy2.SetLineWeight(3);
Sqeezy3.SetPaintingStrategy(PaintingStrategy.POINTS);
Sqeezy3.AssignValueColor(if squeezeDots3 == 1 then Color.DARK_GREEN else Color.DARK_RED);
Sqeezy3.SetLineWeight(3);
Sqeezy4.SetPaintingStrategy(PaintingStrategy.POINTS);
Sqeezy4.AssignValueColor(if squeezeDots5 == 1 then Color.DARK_GREEN else Color.DARK_RED);
Sqeezy4.SetLineWeight(3);
Sqeezy5.SetPaintingStrategy(PaintingStrategy.POINTS);
Sqeezy5.AssignValueColor(if squeezeDots5 == 1 then Color.DARK_GREEN else Color.DARK_RED);
Sqeezy5.SetLineWeight(3);
Sqeezy6.SetPaintingStrategy(PaintingStrategy.POINTS);
Sqeezy6.AssignValueColor(if squeezeDots6 == 1 then Color.DARK_GREEN else  Color.DARK_RED);
Sqeezy6.SetLineWeight(3);
do you or anyone know how to create a scan that when the dot on line 5 changes color (red to green and vice versa)?
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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