Squeeze that works on mobile For ThinkOrSwim

Jimiandjaymason

New member
I got the Squeeze Pro (original code by Mobius and TheBewb) to plot the squeeze signals in the correct color on TOS mobile. Even though its coded for the squeeze signal to be points, you have to go to the indicator settings and change the 4 squeeze signals to "points" instead of "lines" and then you are good to go. I am 100% self taught with coding so I may have gone about it the hard way so anyone that actually knows what they are doing don't bash me too hard LOL.
Untitled-design-2-709x1536.jpg

Code:
#WS Trades converted to mobile TOS
##Assembled by TheBewb using existing Mobius Squeeze Momentum coding and "squeeze" concept made popular by John Carter.
declare lower;
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 ATR1 = Average(TrueRange(high,  close,  low),  length);

def SDev1 = StDev(price, length);

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

def PosUp = pos and up;
def PosDn = pos and dn;
def NegDn = neg and dn;
def NegUp = neg and up;


def conditionF = Fired;
plot squeezelineF = if conditionF then 0 else double.NaN;
squeezelineF.SetPaintingStrategy(PaintingStrategy.POINTS);
squeezelineF.SetDefaultColor(Color.GREEN);

def conditionPS = presqueeze;
plot squeezelinePS = if conditionPS then 0 else double.NaN;
squeezelinePS.SetPaintingStrategy(PaintingStrategy.POINTS);
squeezelinePS.SetDefaultColor(Color.BLACK);

def conditionOS = originalSqueeze;
plot squeezelineOS =  if conditionOS then 0 else double.NaN;
squeezelineOS.SetPaintingStrategy(PaintingStrategy.POINTS);
squeezelineOS.SetDefaultColor(Color.RED);

def conditionES = ExtrSqueeze;
plot squeezelineES =  if conditionES then 0 else double.NaN ;
squeezelineES.SetPaintingStrategy(PaintingStrategy.POINTS);
squeezelineES.SetDefaultColor(Color.ORANGE);

plot momentum = momo;
momentum.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
momentum.AssignValueColor( if PosUp then Color.cyAN else if PosDn then Color.blue else if NegDn then Color.red else if NegUp then Color.yellow else Color.YELLOW);
http://tos.mx/YHPhq7G
 
Last edited by a moderator:

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

Got this installed, bit only showing red and green line at the bottom, and purple line at the top. Any Suggestions ?
 
Got this installed, bit only showing red and green line at the bottom, and purple line at the top. Any Suggestions ?
It does not get painted on Mobile
It could be that ToS made changes to the mobile app. It used to work. I guess it does not anymore.
You could try calling support. But as they suggest not using custom studies on the mobile app. You might not get very far. :(
 
I got the Squeeze Pro (original code by Mobius and TheBewb) to plot the squeeze signals in the correct color on TOS mobile. Even though its coded for the squeeze signal to be points, you have to go to the indicator settings and change the 4 squeeze signals to "points" instead of "lines" and then you are good to go. I am 100% self taught with coding so I may have gone about it the hard way so anyone that actually knows what they are doing don't bash me too hard LOL.


#WS Trades converted to mobile TOS
##Assembled by TheBewb using existing Mobius Squeeze Momentum coding and "squeeze" concept made popular by John Carter.
declare lower;
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 ATR1 = Average(TrueRange(high, close, low), length);

def SDev1 = StDev(price, length);

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

def PosUp = pos and up;
def PosDn = pos and dn;
def NegDn = neg and dn;
def NegUp = neg and up;


def conditionF = Fired;
plot squeezelineF = if conditionF then 0 else double.NaN;
squeezelineF.SetPaintingStrategy(PaintingStrategy.POINTS);
squeezelineF.SetDefaultColor(Color.GREEN);

def conditionPS = presqueeze;
plot squeezelinePS = if conditionPS then 0 else double.NaN;
squeezelinePS.SetPaintingStrategy(PaintingStrategy.POINTS);
squeezelinePS.SetDefaultColor(Color.BLACK);

def conditionOS = originalSqueeze;
plot squeezelineOS = if conditionOS then 0 else double.NaN;
squeezelineOS.SetPaintingStrategy(PaintingStrategy.POINTS);
squeezelineOS.SetDefaultColor(Color.RED);

def conditionES = ExtrSqueeze;
plot squeezelineES = if conditionES then 0 else double.NaN ;
squeezelineES.SetPaintingStrategy(PaintingStrategy.POINTS);
squeezelineES.SetDefaultColor(Color.ORANGE);

plot momentum = momo;
momentum.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
momentum.AssignValueColor( if PosUp then Color.cyAN else if PosDn then Color.blue else if NegDn then Color.red else if NegUp then Color.yellow else Color.YELLOW);

http://tos.mx/YHPhq7G


Untitled-design-2-709x1536.jpg
I never see orange or red points with this script. Can you share some tickers and timeframe with which it would show that?
 
I just pulled up ticker FHN on the daily timeframe and it is still working. Its orange (extra tight squeeze) from 1/3 to 1/10. Let me know if you see it please.
 
I never see orange or red points with this script. Can you share some tickers and timeframe with which it would show that?
It does not get painted on Mobile

Got this installed, bit only showing red and green line at the bottom, and purple line at the top. Any Suggestions ?

I made this video for the settings a while ago. If you are having issues please watch this. It is still working for me.
 
Last edited:
I have been wanting squeeze signals in my ThinkorSwim mobile app so I have decided to create an indicator that will allow me to see when a squeeze is happening. I used existing squeeze pro code as a starting point and altered it to include a loose squeeze, pre-squeeze, original squeeze, and tight squeeze. Loose squeeze and pre-squeeze are turned off by default in the indicator settings. I've gotten rid of the momentum oscillator as this is just designed to show the squeeze signal itself. If you want the momentum oscillator that normally accompanies the squeeze then just add the original TTM_Squeeze indicator to your chart as well and it will show it at the bottom.

The indicator works by placing color coded arrows pointing inwards on the candle according to the level of squeeze.

Yellow = Loose Squeeze
Orange = Pre-Squeeze
Red = Original Squeeze
Dark_Red = Tight Squeeze

Code:
##Assembled by TheBewb using existing Mobius Squeeze Momentum coding and "squeeze" concept made popular by John Carter.

##Further edited by Easleyjr96 to include higher and lower squeeze levels, and optimized to show squeezes on ToS mobile app.

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;
input showpresqueeze = no;
input showextremesqueeze = yes;
input showexhaustsqueeze = no;
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 factorExhaust = 2.5;
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 shiftExhaust = factorExhaust * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def average = MovingAverage(averageType, price, length);

def Avg = average[-displace];

#Defines the keltner channel levels
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 UpperBandKCExhaust = average[-displace] + shiftExhaust[-displace];
def LowerBandKCExhaust = average[-displace] - shiftExhaust[-displace];


#Logic for how tight the squeeze is
def exhsqueeze      = LowerBandBB > LowerBandKCExhaust and UpperBandBB < UpperBandKCExhaust;
def presqueeze      = LowerBandBB > LowerBandKCLow and UpperBandBB < UpperBandKCLow;
def originalSqueeze     = LowerBandBB > LowerBandKCMid and UpperBandBB < UpperBandKCMid;
def ExtrSqueeze     = LowerBandBB > LowerBandKCHigh and UpperBandBB < UpperBandKCHigh;


###Plots the Up Arrows

plot originalsqueezeup = originalsqueeze and !extrsqueeze;
originalsqueezeup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
originalsqueezeup.SetDefaultColor(Color.RED);

plot presqueezeup = presqueeze and showpresqueeze and !originalsqueeze;
presqueezeup.SetPaintingStrategy(PaintingStrategy.BOOLEAn_ARROW_UP);
presqueezeup.SetDefaultColor(Color.Orange);

plot extrsqueezeup = extrSqueeze and showextremesqueeze;
extrsqueezeup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
extrsqueezeup.SetDefaultColor(Color.Dark_Red);

plot exhsqueezeup = exhsqueeze and showexhaustsqueeze and !presqueeze;
exhsqueezeup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
exhsqueezeup.SetDefaultColor(Color.Yellow);

###Plots the Down Arrows

plot originalsqueezedown = originalsqueeze and !extrsqueeze;
originalsqueezedown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
originalsqueezedown.SetDefaultColor(Color.RED);

plot presqueezedown = presqueeze and showpresqueeze and !originalsqueeze;
presqueezedown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
presqueezedown.SetDefaultColor(Color.Orange);

plot extrsqueezedown = extrSqueeze and showextremesqueeze;
extrsqueezedown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_down);
extrsqueezedown.SetDefaultColor(Color.Dark_Red);

plot exhsqueezedown = exhsqueeze and showexhaustsqueeze and !presqueeze;
exhsqueezedown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_down);
exhsqueezedown.SetDefaultColor(Color.Yellow);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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