Mobius’ Momentum Squeeze for ThinkorSwim

J007RMC

J007RMC

Well-known member
2019 Donor
VIP
I came across this Mobius momentum squeeze today the first time ive seen it.

https://tos.mx/8q82Rb0
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 price = close;
input SDmult = 2.0;
input ATRmult = 1.5;
   def K = (Highest(High, length) + Lowest(low, length)) /
2 + ExpAverage(close, length);
plot Momo = Inertia(price - 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(close, length);
def Avg = Average(close, length);
def ATR = Average(TrueRange(high, close, low), length);
def SDup = Avg + (SdMult * Sd);
def ATRup = Avg + (AtrMult * ATR);
plot Squeeze = if SDup < ATRup
then 0
else Double.NaN;
Squeeze.SetPaintingStrategy(PaintingStrategy.Points);
Squeeze.SetLineWeight(3);
Squeeze.SetDefaultColor(Color.Red);
plot zero = if IsNaN(close) or !IsNaN(Squeeze) then Double.NaN else 0;
zero.SetPaintingStrategy(PaintingStrategy.Points);
zero.SetLineWeight(3);
zero.SetDefaultColor(Color.Green);
AddLabel(!isNaN(Squeeze), "Squeeze", if isAscending(Momo)
then Color.Green
else Color.Red);
# End Code - Momentum Squeeze
 
T

tomsk

Well-known member
VIP
I saw that in TSL several years ago According to Mobius it precisely replicates the TOS TTM_Squeeze. At default settings the output is the same as the TTM_Squeeze.
 
J007RMC

J007RMC

Well-known member
2019 Donor
VIP
Ahh thanks is there a way to improve on default setting maybe just curious..
 
J007RMC

J007RMC

Well-known member
2019 Donor
VIP
Wow absolutely identical but the label may in some way be helpful.
 
T

tomsk

Well-known member
VIP
Wow absolutely identical but the label may in some way be helpful.

That was the reason why Mobius replicated it, and you're right, it allows coders to add ore info to suit the needs.
The standard TOS TTM Squeeze has the source code locked so that Mobius study was really helpful
 
T

tomsk

Well-known member
VIP
Thanks tomsk very interesting.

There is a commercial study called TTM Squeeze Pro that is being claimed to generate earlier signals than the regular TTM Squeeze.
As best as I can understand it they do some computation in the KeltnerChannel values by using 3 different "factors" - high, low and mid and some some relationship tests with the BollingerBand. The details escape me but that's how I understood it
 
J007RMC

J007RMC

Well-known member
2019 Donor
VIP
Took this off a website same updated indicator behind John Carter's famous $1.4 Million TSLA Trade
 
J007RMC

J007RMC

Well-known member
2019 Donor
VIP
Squeeze Momentum Indicator [LazyBear]

This is a derivative of John Carter's "TTM Squeeze" volatility indicator, as discussed in his book "Mastering the Trade" (chapter 11).

Black crosses on the midline show that the market just entered a squeeze (Bollinger Bands are with in Keltner Channel). This signifies low volatility, market preparing itself for an explosive move (up or down). Gray crosses signify "Squeeze release".

Mr.Carter suggests waiting till the first gray after a black cross, and taking a position in the direction of the momentum (for ex., if momentum value is above zero, go long). Exit the position when the momentum changes (increase or decrease --- signified by a color change). My (limited) experience with this shows, an additional indicator like ADX / WaveTrend, is needed to not miss good entry points. Also, Mr.Carter uses simple momentum indicator , while I have used a different method (linreg based) to plot the histogram.

More info:
- Book: Mastering The Trade by John F Carter

Code:
//
// @author LazyBear
// List of all my indicators: https://www.tradingview.com/v/4IneGo8h/
//
study(shorttitle = "SQZMOM_LB", title="Squeeze Momentum Indicator [LazyBear]", overlay=false)
length = input(20, title="BB Length")
mult = input(2.0,title="BB MultFactor")
lengthKC=input(20, title="KC Length")
multKC = input(1.5, title="KC MultFactor")
useTrueRange = input(true, title="Use TrueRange (KC)", type=bool)
// Calculate BB
source = close
basis = sma(source, length)
dev = multKC * stdev(source, length)
upperBB = basis + dev
lowerBB = basis - dev
// Calculate KC
ma = sma(source, lengthKC)
range = useTrueRange ? tr : (high - low)
rangema = sma(range, lengthKC)
upperKC = ma + rangema * multKC
lowerKC = ma - rangema * multKC
sqzOn  = (lowerBB > lowerKC) and (upperBB < upperKC)
sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC)
noSqz  = (sqzOn == false) and (sqzOff == false)
val = linreg(source  -  avg(avg(highest(high, lengthKC), lowest(low, lengthKC)),sma(close,lengthKC)),
            lengthKC,0)
bcolor = iff( val > 0,
iff( val > nz(val[1]), lime, green),
iff( val < nz(val[1]), red, maroon))
scolor = noSqz ? blue : sqzOn ? black : gray
plot(val, color=bcolor, style=histogram, linewidth=4)
plot(0, color=scolor, style=cross, linewidth=2)
 
Last edited by a moderator:
K

Kimberly

New member
There is a commercial study called TTM Squeeze Pro that is being claimed to generate earlier signals than the regular TTM Squeeze.
As best as I can understand it they do some computation in the KeltnerChannel values by using 3 different "factors" - high, low and mid and some some relationship tests with the BollingerBand. The details escape me but that's how I understood it

Found this comment regarding what is different with the TTM Squeeze Pro version:

https://www.tradingview.com/script/TAAt6eRX-Squeeze-PRO-Indicator-Makit0/#tc2691249
"The squeeze pro from John Carter uses 3 colors to identify the 3 different compression levels, black for 2xBB<2xKC, red for 2xBB<1.5xKC and yellow for 2xBB<1xKC (BB->bollinger bands, KC->keltner channles), I'm using orange, red and yellow since I like my charts background in black and for me those colors do the trick."
 
J

justAnotherTrader

Member
VIP
This is a Mobius script. It is the bottom indicator in my screenshot



Code:
# Momentum Squeeze and Volume Mod 08.17.18
# Mobius
# Added Squeeze Label with directional color
# Label is green when momentum is ascending, red when descending
# Added UI for separate Squeeze and Oscillator lenghts

# This code precisely replicates TTM_Squeeze. At default settings
# the output is the same as TTM_Squeeze. Top is Momentum squeeze
# study and bottom is TTM_Squeeze. The Oscillator can be adjusted
# separately with this version. I prefer the oscillator at 13, as
# it makes it more timely
#
# Squeeze was originated by John Bollinger and the Momentum Oscillator
# has been around long before Carter's version. He just painted it
# those colors.
#
# Some years ago we ran some statistics on squeeze breakouts and
# it was right around 50/50 with some variance with price near high
# volume pivots being a bit more easily read.
#
# If there was a high volume pivot within 3 or 4 bars of a low and
# then a squeeze, the probability of an expansion in price upward was
# nearer 1 st dev. If there was a low volume high pivot near a squeeze
# the probability was for a downward expansion of price.
#
# Squeeze in those cases denotes the indecision (price compression)
# before a trend change. The same price compression is what the
# SuperTrend code picks up on

# Modified by blt, 7.26.2016
# Bars painted GRAY if we are in a squeeze, BLUE if we are long and
# ORANGE if we are short. Also added addverticalline when squeeze fires

declare lower;

input Slength = 20; #hint Slength: Length for Squeeze
input Klength = 20; #hint Klength: Length for Oscillator
input price = close;
input SDmult = 2.0;
input ATRmult = 1.5;

def K = (Highest(high, Klength) + Lowest(low, Klength)) /
2 + ExpAverage(close, Klength);
plot Momo = Inertia(price - K / 2, Klength);
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(close, Slength);
def Avg = Average(close, Slength);
def ATR = Average(TrueRange(high, close, low), Slength);
def SDup = Avg + (SDmult * SD);
def ATRup = Avg + (ATRmult * ATR);
plot Squeeze = if SDup < ATRup
then 0
else Double.NaN;
Squeeze.SetPaintingStrategy(PaintingStrategy.POINTS);
Squeeze.SetLineWeight(3);
Squeeze.SetDefaultColor(Color.RED);
plot zero = if IsNaN(close) or !IsNaN(Squeeze) then Double.NaN else 0;
zero.SetPaintingStrategy(PaintingStrategy.POINTS);
zero.SetLineWeight(3);
zero.SetDefaultColor(Color.GREEN);
AddLabel(!IsNaN(Squeeze), "Squeeze", if IsAscending(Momo)
then Color.GREEN
else Color.RED);
# End Code - Momentum Squeeze

AddVerticalLine(!IsNaN(squeeze[1]) and IsNaN(squeeze), "Fired", Color.RED, Curve.FIRM);


#ADDED Volume###################################################################
#Colored Volume By Ethans080901
#Mod TroyX-8-17-18
#If today's closing price and volume is greater than 'n' days ago, color green
#If today's closing price is greater than 'n' days ago but volume is not, color blue
#If today's closing price is less than 'n' days ago, color orange
#If today's closing price is less than 'n' days ago but volume is not, color red

input n = 10;

def CN = Average(close, n);
def VN = Average(volume, n);
def G = close > CN and volume > VN ;
def B = close > CN and volume == VN;
def O = close < CN and volume == VN;
def R = close < CN and volume >= VN;

#Added volume Label
AddLabel( G, "Bullish Volume" , Color.CYAN); #Strong Bull
AddLabel( B, "Bullish Volume" , Color.BLUE); #Weak Bull
AddLabel( O, "Bearish Volume" , Color.YELLOW); #Weak Bear
AddLabel( R, "Bearish Volume" , Color.ORANGE); #Strong Bear

#How to use:
#Buy on Green or Blue
#Sell on Yellow or Orange

#End
 
Last edited:

Similar threads

Top