TTM Squeeze Format, Scan, Watchlist, Label For ThinkOrSwim

This code also doesn't work, TOS. says "
No such variable: Momo at 13:28
No such variable: Momo at 13:40
No such variable: Momo at 14:18
No such variable: Momo at 14:31"
You had to have copied it wrong. Works fine on my end. Momo is defined on line 16.
 

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

I just copied and pasted it like 10 times. Now TOS says "Exactly one plot expected" and won't let me pass the "OK" button.
oh dude no, you need to paste this to as a new study on the CHART tab. Then when you go to scan tab it will appear as a choice. You can't paste it on the scan tab because the formatting is different and adding from the chart area allows the option of dropdown menus
 
oh dude no, you need to paste this to as a new study on the CHART tab. Then when you go to scan tab it will appear as a choice. You can't paste it on the scan tab because the formatting is different and adding from the chart area allows the option of dropdown menus
Ohh okay. It works. Where do I find it on the scan tab?
 
Ohh okay. It works. Where do I find it on the scan tab?
Select add condition, then Study, then you'll add it by whatever name you saved it as, then select whatever you want from the dropdown menu next to Plot, then select "is true" in the middle column, and click OK.
 
Thank you so much!! When you put “is true” then “1 bar ago”, it shows squeezes that already fired. Is it possible to get in before the squeeze fires? Maybe a bar or two before. Therefore, we buy, bar or two later, it fires to the upside.
 
Sorry but need help here. I think I'm missing something. I want to scan for only "buy alerts" with this indicator. Do I need to edit the condition input when setting up the scan? Kindly provide step by step if possible. Appreciate that very much! Thank you!

* Also, comment appears in indicator code: "invalid statement: 2 at 1:1" How do I correct this? Thank you again! *
I think it is referring to this:

2
def HiLo = Min(high - low, 1.5 * Average(high - low, ATRPeriod));
 
Last edited:
Sorry but need help here. I think I'm missing something. I want to scan for only "buy alerts" with this indicator. Do I need to edit the condition input when setting up the scan? Kindly provide step by step if possible. Appreciate that very much! Thank you!

* Also, comment appears in indicator code: "invalid statement: 2 at 1:1" How do I correct this? Thank you again! *
I think it is referring to this:

2
def HiLo = Min(high - low, 1.5 * Average(high - low, ATRPeriod));
Don't need to edit anything. Just switch the dropdown menu where it says Plot to "BreakoutBull" and that will show you breakouts to the upside coming out of the squeeze. If you want just the histogram changing directions and coming back up to bull, switch the menu to "beartrendchange". If you want the histogram changing directions to bull WHILE STILL in a squeeze, change it to "squeeze_changetobull"
 
I'd be glad to change the names of the options if everybody can agree on titles that are more clear? Wasn't trying to make the thing confusing hahah
 
@kelbadawi Left click on the little gear icon under your watchlist > Customize > under the dropdown menu look for Custom Quotes
 
what is the best strategy time frame for this column? i set mine to 1HR, SPCE showing bright red "B 8". just trying to understand how to use it @BenTen thank you so much
 
Would there be any way to incorporate arrows based on which way the momentum bars fire after the squeeze ? I currently use the code from mobius but am not able to post it here at the moment.
 
Last edited:
@Liquidity I found Mobius' Momentum Squeeze and modified the code. I'm not certain what you consider "up" or "down", so I plotted the arrows to signal "up" if the squeeze fires when the momentum is greater than 0, and to signal "down" if the squeeze fires when momentum is less than 0. If you want it to signal differently, post the changes you want.

Code:
# Squeeze Momentum Arrow Signals
# Uses Momentum Squeeze code by Mobius
# Edited by Pensar 07/23/2020
# Removed the original plots and label, and plotted arrows on price to indicate
# momentum direction after the squeeze fires

declare upper;

input length = 20; #hint length: Length for average calculation
input SDmult = 2.0;
input ATRmult = 1.5;

def c = close;
def h = high;
def l = low;
def K = (Highest(h, length) + Lowest(l, length))/2 + ExpAverage(c, length);
def Momo = if isNaN(close) then double.nan else Inertia(c - K / 2, length);
def SD = StDev(c, length);
def Avg = Average(c, length);
def ATR = Average(TrueRange(h, c, l), length);
def SDup = Avg + (SdMult * Sd);
def ATRup = Avg + (AtrMult * ATR);
def Squeeze = if isNaN(c) then double.nan else if SDup < ATRup then 0 else Double.NaN;
def zero = if IsNaN(c) or !IsNaN(Squeeze) then Double.NaN else 0;

plot arrow_up = if IsNaN(c) or !IsNaN(Squeeze) or !IsNaN(zero[1]) then Double.NaN
                else if Momo > 0 then low else Double.NaN;
     arrow_up.setpaintingstrategy(paintingstrategy.arrow_up);
     arrow_up.setdefaultcolor(color.cyan);
     arrow_up.setlineweight(3);

plot arrow_dn = if IsNaN(c) or !IsNaN(Squeeze) or !IsNaN(zero[1]) then Double.NaN
                else if Momo < 0 then high else Double.NaN;
     arrow_dn.setpaintingstrategy(paintingstrategy.arrow_down);
     arrow_dn.setdefaultcolor(color.magenta);
     arrow_dn.setlineweight(3);

# end code
 
Here's Mobius' Momentum Squeeze code. It is identical to JC's TTM_Squeeze code on TOS that has the locked source code.

Code:
# Momentum Squeeze
# Mobius
# Added Squeeze Label with directional color
# Label is green when momentum is ascending, red when descending

declare lower;

input length = 20; #hint length: Length for average calculation
input SDmult = 2.0;
input ATRmult = 1.5;

   def c = close;
   def h = high;
   def l = low;
   def K = (Highest(h, length) + Lowest(l, length)) /
               2 + ExpAverage(c, length);
  plot Momo = if isNaN(close)
              then double.nan
              else Inertia(c - K / 2, length);
       Momo.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
       Momo.setLineWeight(3);
       Momo.assignValueColor(if Momo > Momo[1] and Momo > 0
                             then Color.Cyan
                             else if Momo > 0 and Momo < Momo[1]
                             then Color.Blue
                             else if Momo < 0 and Momo < Momo[1]
                             then Color.Red
                             else Color.Yellow);

def SD = StDev(c, length);
def Avg = Average(c, length);
def ATR = Average(TrueRange(h, c, l), length);
def SDup = Avg + (SdMult * Sd);
def ATRup = Avg + (AtrMult * ATR);
plot Squeeze = if isNaN(c)
               then double.nan
               else if SDup < ATRup
               then 0
               else Double.NaN;
     Squeeze.SetPaintingStrategy(PaintingStrategy.Points);
     Squeeze.SetLineWeight(1);
     Squeeze.SetDefaultColor(Color.Red);
plot zero = if IsNaN(c) or !IsNaN(Squeeze) then Double.NaN else 0;
     zero.SetPaintingStrategy(PaintingStrategy.Points);
     zero.SetLineWeight(1);
     zero.SetDefaultColor(Color.Green);
AddLabel(!isNaN(Squeeze), "Squeeze", if isAscending(Momo)
                                     then Color.Green
                                     else Color.Red);
# End Code - Momentum Squeeze
 
@BenTen Can you please help with the scanner.. not sure how to make this line as plot as it has multiple conditions with concat....
Code:
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);

I was looking for if squeeze fire long or short ... and add that to watch list. Do I need to have multiple scanner for long and short? Appreciate your help.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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