Mobius’ Momentum Squeeze for ThinkorSwim

I just found this script online. I'm not sure if it is already shared.

Trading Software: thinkorswim
Based on: TTM Squeeze (Bollinger Bands & Keltner Channels), Elliot Waves, & ParobolicSAR
Description: This study strives to emulate and optimize the TTM Squeeze study. The red squeeze indicator fires when the symbol’s Bollinger Bands are inside the symbol’s Keltner Channel. The green and red arrows are Parabolic SAR crossover indicators. The green/red waves are Wave A of the Elliot Waves, and the yellow/blue waves are Wave C of the Elliot Waves. The chart label outlines the squeeze resolution in an attempt to predict the breakout direction of the squeeze.

Optimal Long Sequence:
  1. Histogram shift from light red to dark red with values increasing toward the index line, confirming a shift from distribution to accumulation.
  2. Red Squeeze indicators firing indicating consolidation; Bollinger Band compression and volatility increase.
  3. A green up arrow indicating the Parabolic Stop and Reverse has made a bullish crossover.
Optimal Short Sequence is the reverse of the above (histogram from dark green to light green, red squeeze indicators firing, and red arrow for bearish Parabolic SAR crossover).

Code:
declare lower;

input price = CLOSE;
input ShortLength1 = 5;
input ShortLength2 = 14;
input ShortLength3 = 5;
input LongLength1 = 12;
input LongLength2 = 55;
input LongLength3 = 7;

# Momentum Oscillators

  plot MS = Average(Average(price, ShortLength1) - Average(price, ShortLength2), ShortLength3);
  plot MS2 = Average(Average(price, LongLength1) - Average(price, LongLength2), LongLength3);
# Wave A
  def MSGreens = if (MS >= 0, MS, 0);
  def MSReds = if (MS < 0, MS, 0);
# Wave C
  def MS2Blues = if (MS2 >= 0, MS2, 0);
  def MS2Yellows = if (MS2 < 0, MS2, 0);

  plot MS_Pos = MSGreens;
       MS_Pos.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
       MS_Pos.AssignValueColor(if MSGreens < MSGreens[1] then Color.GREEN else Color.DARK_GREEN);

  plot MS_Neg = MSReds;
       MS_Neg.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
       MS_Neg.AssignValueColor(if MSReds < MSReds[1] then CreateColor(255, 60, 60) else Color.DARK_RED);

  plot MS2_Pos = MS2Blues;
       MS2_Pos.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
       MS2_Pos.AssignValueColor(if MS2Blues < MS2Blues[1] then Color.BLUE else Color.CYAN);

  plot MS2_Neg = MS2Yellows;
       MS2_Neg.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
       MS2_Neg.AssignValueColor(if MS2Yellows < MS2Yellows[1] then Color.YELLOW else Color.LIGHT_RED);

# Squeeze Indicator

input length = 20;
input nK = 1.5;
input nBB = 2.0;

  def BBHalfWidth = stdev(price, length);
  def KCHalfWidth = nK * AvgTrueRange(high, close, low, length);
  plot isSqueezed = nBB * BBHalfWidth / KCHalfWidth < 1;
       isSqueezed.hide();
  plot BBS_Ind = if(isSqueezed, 0, Double.NAN);
       BBS_Ind.SetPaintingStrategy(PaintingStrategy.SQUARES);
       BBS_Ind.SetLineWeight(3);
       BBS_Ind.AssignValueColor(Color.RED);

# Bollinger Resolution

  def BBSMA = Average(price, length);
  def BBSMAL = BBSMA + (-nBB * BBHalfWidth);
  def BBSMAU = BBSMA + (nBB * BBHalfWidth);
  def PerB = roundUp((price - BBSMAL) / (BBSMAU - BBSMAL) * 100, 0);
  AddChartLabel(yes, concat("%B: ", PerB), if PerB < 0 then color.YELLOW else if PerB > 0 and PerB[1] < 0 then color.GREEN else color.WHITE);

# Parabolic SAR Signal

input accelerationFactor = 0.0275;
input accelerationLimit = 0.2;

  def SAR = ParabolicSAR(accelerationFactor = accelerationFactor, accelerationLimit = accelerationLimit);

  plot bearishCross = Crosses(SAR, price, CrossingDirection.ABOVE);
       bearishCross.hide();
  plot signalDown = if(bearishCross, 0, Double.NAN);
       signalDown.SetPaintingStrategy(PaintingStrategy.Arrow_Down);
       signalDown.SetLineWeight(3);
       signalDown.AssignValueColor(Color.DOWNTICK);

  plot bullishCross = Crosses(SAR, price, CrossingDirection.BELOW);
       bullishCross.hide();
  plot signalUp =  if(bullishCross, 0, Double.NAN);
       signalUp.SetPaintingStrategy(PaintingStrategy.Arrow_Up);
       signalUp.SetLineWeight(3);
       signalUp.AssignValueColor(Color.UPTICK);
where to identify the Red Squeeze indicators on the study?
 

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

@cswu1211 This is the part of the script that plots the Red Squeezed
BBS_Ind is the element. This part of the script states BBS_Ind plots size 3 red squares if isSqueezed.
Ruby:
 plot BBS_Ind = if(isSqueezed, 0, Double.NAN);
       BBS_Ind.SetPaintingStrategy(PaintingStrategy.SQUARES);
       BBS_Ind.SetLineWeight(3);
       BBS_Ind.AssignValueColor(Color.RED);
 
To scan add the following code to the study:
Code:
plot scan = SDup < ATRup ;
scan.hide();
Scan for: scan is true
 
I have Mobius Squeeze code here that I would like to use only the squeeze part as you can see, I take away already everything else. Now I want to hide the green point (the not squeeze part) and leave only the high, middle and low squeeze points. can some show me how to done that?

Code:
declare lower;

def length = 20;
def nDev = 2.0;
def averageType = AverageType.EXPONENTIAL;

def sDev = StDev(data = close, length = length);
def MidLineBB = MovingAverage(averageType, data = close, length = length);
def LowerBandBB = MidLineBB + -nDev * sDev;
def UpperBandBB = MidLineBB + nDev * sDev;

def factorhigh = 1.0;
def factormid = 1.5;
def factorlow = 2.0;

def shifthigh = factorhigh * MovingAverage(averageType, TrueRange(high, close, low), length);
def shiftMid = factormid * MovingAverage(averageType, TrueRange(high, close, low), length);
def shiftlow = factorlow * MovingAverage(averageType, TrueRange(high, close, low), length);
def average = MovingAverage(averageType, close, length);

def UpperBandKCLow = average[-0] + shiftlow[-0];
def LowerBandKCLow = average[-0] - shiftlow[-0];

def UpperBandKCMid = average[-0] + shiftMid[-0];
def LowerBandKCMid = average[-0] - shiftMid[-0];

def UpperBandKCHigh = average[-0] + shifthigh[-0];
def LowerBandKCHigh = average[-0] - shifthigh[-0];

def preSqueeze = LowerBandBB > LowerBandKCLow and UpperBandBB < UpperBandKCLow;
def originalSqueeze = LowerBandBB > LowerBandKCMid and UpperBandBB < UpperBandKCMid;
def ExtrSqueeze = LowerBandBB > LowerBandKCHigh and UpperBandBB < UpperBandKCHigh;

plot squeezeline = if IsNaN(close) then Double.NaN else 0;
squeezeline.AssignValueColor(if ExtrSqueeze then Color.VIOLET else if originalSqueeze then Color.ORANGE else if preSqueeze then Color.BLACK else Color.GREEN);
squeezeline.SetPaintingStrategy(PaintingStrategy.POINTS);
squeezeline.SetLineWeight(4);
 
I have Mobius Squeeze code here that I would like to use only the squeeze part as you can see, I take away already everything else. Now I want to hide the green point (the not squeeze part) and leave only the high, middle and low squeeze points. can some show me how to done that?

Code:
declare lower;

def length = 20;
def nDev = 2.0;
def averageType = AverageType.EXPONENTIAL;

def sDev = StDev(data = close, length = length);
def MidLineBB = MovingAverage(averageType, data = close, length = length);
def LowerBandBB = MidLineBB + -nDev * sDev;
def UpperBandBB = MidLineBB + nDev * sDev;

def factorhigh = 1.0;
def factormid = 1.5;
def factorlow = 2.0;

def shifthigh = factorhigh * MovingAverage(averageType, TrueRange(high, close, low), length);
def shiftMid = factormid * MovingAverage(averageType, TrueRange(high, close, low), length);
def shiftlow = factorlow * MovingAverage(averageType, TrueRange(high, close, low), length);
def average = MovingAverage(averageType, close, length);

def UpperBandKCLow = average[-0] + shiftlow[-0];
def LowerBandKCLow = average[-0] - shiftlow[-0];

def UpperBandKCMid = average[-0] + shiftMid[-0];
def LowerBandKCMid = average[-0] - shiftMid[-0];

def UpperBandKCHigh = average[-0] + shifthigh[-0];
def LowerBandKCHigh = average[-0] - shifthigh[-0];

def preSqueeze = LowerBandBB > LowerBandKCLow and UpperBandBB < UpperBandKCLow;
def originalSqueeze = LowerBandBB > LowerBandKCMid and UpperBandBB < UpperBandKCMid;
def ExtrSqueeze = LowerBandBB > LowerBandKCHigh and UpperBandBB < UpperBandKCHigh;

plot squeezeline = if IsNaN(close) then Double.NaN else 0;
squeezeline.AssignValueColor(if ExtrSqueeze then Color.VIOLET else if originalSqueeze then Color.ORANGE else if preSqueeze then Color.BLACK else Color.GREEN);
squeezeline.SetPaintingStrategy(PaintingStrategy.POINTS);
squeezeline.SetLineWeight(4);

See if this helps by replacing the following line in the code

Capture.jpg
Ruby:
plot squeezeline = if IsNaN(close)
                   then Double.NaN
                   else if ExtrSqueeze or originalSqueeze or preSqueeze
                   then 0 else Double.NaN;
 
yes exactly that. can you help me with a label because the one I create count me wrong. I want to have a label that tell me how many squeeze is happening?

Try this.
Some of the squeezes overlap so you will get overlapping colors and more than one squeeze will a count.
You can uncomment the portion of the count labels if you only want the label to show if there is a count for a particular squeeze.


Capture.jpg
Ruby:
declare lower;

def length = 20;
def nDev = 2.0;
def averageType = AverageType.EXPONENTIAL;

def sDev = StDev(data = close, length = length);
def MidLineBB = MovingAverage(averageType, data = close, length = length);
def LowerBandBB = MidLineBB + -nDev * sDev;
def UpperBandBB = MidLineBB + nDev * sDev;

def factorhigh = 1.0;
def factormid = 1.5;
def factorlow = 2.0;

def shifthigh = factorhigh * MovingAverage(averageType, TrueRange(high, close, low), length);
def shiftMid = factormid * MovingAverage(averageType, TrueRange(high, close, low), length);
def shiftlow = factorlow * MovingAverage(averageType, TrueRange(high, close, low), length);
def average = MovingAverage(averageType, close, length);

def UpperBandKCLow = average[-0] + shiftlow[-0];
def LowerBandKCLow = average[-0] - shiftlow[-0];

def UpperBandKCMid = average[-0] + shiftMid[-0];
def LowerBandKCMid = average[-0] - shiftMid[-0];

def UpperBandKCHigh = average[-0] + shifthigh[-0];
def LowerBandKCHigh = average[-0] - shifthigh[-0];

def preSqueeze      = LowerBandBB > LowerBandKCLow and UpperBandBB < UpperBandKCLow;
def originalSqueeze = LowerBandBB > LowerBandKCMid and UpperBandBB < UpperBandKCMid;
def ExtrSqueeze     = LowerBandBB > LowerBandKCHigh and UpperBandBB < UpperBandKCHigh;

def precount      = if !preSqueeze
                    then 0
                    else if preSqueeze
                    then precount[1] + 1
                    else precount[1];
def originalcount = if !originalSqueeze
                    then 0
                    else if originalSqueeze
                    then originalcount[1] + 1
                    else originalcount[1];
def Extrcount     = if !ExtrSqueeze
                    then 0
                    else if ExtrSqueeze
                    then Extrcount[1] + 1
                    else Extrcount[1];

input showlabels = yes;
AddLabel(showlabels #and precount
        , "Precount : " + precount, Color.BLACK);
AddLabel(showlabels #and originalcount
        , "Originalcount : " + originalcount, Color.ORANGE);
AddLabel(showlabels #and extrcount
        , "Extrcount : " + Extrcount, Color.VIOLET);

plot squeezeline = if IsNaN(close)
                   then Double.NaN
                   else if ExtrSqueeze or originalSqueeze or preSqueeze
                   then 0 else Double.NaN;
squeezeline.AssignValueColor(if ExtrSqueeze then Color.VIOLET else if originalSqueeze then Color.ORANGE else if preSqueeze then Color.BLACK else Color.GREEN);
squeezeline.SetPaintingStrategy(PaintingStrategy.POINTS);
squeezeline.SetLineWeight(4);
 
Try this.
Some of the squeezes overlap so you will get overlapping colors and more than one squeeze will a count.
You can uncomment the portion of the count labels if you only want the label to show if there is a count for a particular squeeze.
thanks for the help, I end put it the label like this

Code:
AddLabel(yes, " Low: " + precount + " | " + " Mid: " + oriCount + " | " + " High: " + ExtCount + "  ", Color.YELLOW);
 
Last edited:
Try this.
Some of the squeezes overlap so you will get overlapping colors and more than one squeeze will a count.
You can uncomment the portion of the count labels if you only want the label to show if there is a count for a particular squeeze.
As a last question, I have another calculation code. I just finishing to put a signal indicator together and with this I think I can make a start on my indicator. I got some level signals that I make them manually and my code become to long in my opinion, I think it could be more simple.

my level signal point start at 1.8 and I want every time increase 0.5 shows me again another point signal and again for every time it keep increasing 0.5

here is the code I got for now for that part

Code:
def obL1 = 1.8;
def obL2 = 2.3;
def obL3 = 2.8;
def obL4 = 3.3;

plot mSig = if !IsNaN(close) then flen else Double.NaN;
mSig.SetDefaultColor(Color.MAGENTA);
mSig.SetLineWeight(2);

plot exUp1 = if mSig crosses above obL1 then mSig else Double.NaN;
exUp1.SetPaintingStrategy(PaintingStrategy.POINTS);
exUp1.SetDefaultColor(Color.yellow;
exUp1.SetLineWeight(5);

plot exDn1 = if mSig crosses below -obL1 then mSig else Double.NaN;
exDn1.SetPaintingStrategy(PaintingStrategy.POINTS);
exDn1.SetDefaultColor(Color.yellow;
exDn1.SetLineWeight(5);
 
As a last question, I have another calculation code. I just finishing to put a signal indicator together and with this I think I can make a start on my indicator. I got some level signals that I make them manually and my code become to long in my opinion, I think it could be more simple.

my level signal point start at 1.8 and I want every time increase 0.5 shows me again another point signal and again for every time it keep increasing 0.5

here is the code I got for now for that part

Code:
def obL1 = 1.8;
def obL2 = 2.3;
def obL3 = 2.8;
def obL4 = 3.3;

plot mSig = if !IsNaN(close) then flen else Double.NaN;
mSig.SetDefaultColor(Color.MAGENTA);
mSig.SetLineWeight(2);

plot exUp1 = if mSig crosses above obL1 then mSig else Double.NaN;
exUp1.SetPaintingStrategy(PaintingStrategy.POINTS);
exUp1.SetDefaultColor(Color.yellow;
exUp1.SetLineWeight(5);

plot exDn1 = if mSig crosses below -obL1 then mSig else Double.NaN;
exDn1.SetPaintingStrategy(PaintingStrategy.POINTS);
exDn1.SetDefaultColor(Color.yellow;
exDn1.SetLineWeight(5);

It is difficult to determine how much optimization of the code can be done with the above snippet of the code.

Nonetheless, it looks like you could try combining the two plot statements into one statement

Ruby:
plot exUp1 = if mSig crosses above obL1 or mSig crosses below -obL1 then mSig else Double.NaN;
exUp1.SetPaintingStrategy(PaintingStrategy.POINTS);
exUp1.SetDefaultColor(color.yellow);
exUp1.SetLineWeight(5);
 
It is difficult to determine how much optimization of the code can be done with the above snippet of the code.

Nonetheless, it looks like you could try combining the two plot statements into one statement
you are totally right! Well I got 8 times that type of signal that of course with your idea I did resume the amount of code even more as you can see here. but what I was thinking if I can create a calculation that after the signal gets to obL1 and keep increasing and reach extra 0.5 more the signal fire another Point and so on? if you see my level increases every 0.5
 
Last edited:
you are totally right! Well I got 8 times that type of signal that of course with your idea I can resume the amount of code to half.
but what I was thinking if I can create a calculation that after the signal gets to obL1 and keep increasing and reach extra 0.5 more the signal fire another Point and so on?

Here is something that you might help. I used an example of AAL and price as I do not know enough about your code's obL's.

Ruby:
def cond = if close crosses above 17
           then 1
           else if cond[1]==1 and close crosses above 17.50
           then 1
           else if cond[1]==1 and close crosses above 18
           then 1
           else 0;
plot data = cond;
data.setpaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
Capture.jpg
 
Here is something that you might help. I used an example of AAL and price as I do not know enough about your code's obL's.
I did this for now

Code:
plot ext1 = if mSig crosses above obL1 or mSig crosses below -obL1 then mSig else
            if mSig crosses above obL2 or mSig crosses below -obL2 then mSig else
            if mSig crosses above obL3 or mSig crosses below -obL3 then mSig else
            if mSig crosses above obL4 or mSig crosses below -obL4 then mSig else Double.NaN;
ext1.SetPaintingStrategy(PaintingStrategy.POINTS);
ext1.SetDefaultColor(CreateColor(255,255,0));

but I will see what I can do with your code but I will be hard on me since I'm no to expirience in thinkscript, but I will try by the way my idea is for lower indicator
 
This is a Mobius script. It is the bottom indicator in my screenshot

XTCBPNQ.png


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
Care to share your breakout2 scan on the watchlists ?
 
This is a Mobius script. It is the bottom indicator in my screenshot

XTCBPNQ.png


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
The volume label is not showing for me, there is anything else that have to be done ?
Thanks
 
The volume label is not showing for me, there is anything else that have to be done ?
Thanks
@Mattyb740
Did you know that clicking on a member's avatar will allow you to see when a member was last seen on the uTS forum? @justAnotherTrader has not been seen in a while. :(

@chincha
No, there is no volume data involved in calculating a squeeze. "The Squeeze" is a term for when price movement is in consolidation, So no there is no volume label in the squeeze script.

However, if you are interested in buying / selling volume pressure which the label in the image is "probably" referring to, here is a simple one: https://usethinkscript.com/threads/...essure-indicator-labels-for-thinkorswim.8466/
Search the forum for buy / sell pressure. There are many more studies available.
 
thanks for the help, I end put it the label like this

Code:
AddLabel(yes, " Low: " + precount + " | " + " Mid: " + oriCount + " | " + " High: " + ExtCount + "  ", Color.YELLOW);
How would you just put the label on top without a lower indicator. Easier to see, and saves room at the bottom.
 
MOBIUS MOMENTUM SQUEEZE V02 dated 4/1/2020
Ruby:
# Momentum Squeeze V02
# Mobius
# V02.04.01.2020
# New faster Momentum Oscillator with outer band markers. New more accurate Squeeze indication.

declare lower;

input n = 20;

def c = close;
def mean = Inertia(c, n);
def SD = Sqrt((fold i = 0 to n
               with s
               do s + Sqr(mean - GetValue(c, i))) / n);
plot Momo = Inertia((c - mean) / SD, Floor(n ));
     Momo.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
     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.dark_Red
                           else Color.Yellow);
def upper = mean + (2 * SD);
def lower = mean - (2 * SD);
def W = (upper - lower) / mean;
def B = Highest(W, n * 2);
def Sq = Lowest(W, n * 2);
plot Squeeze = if ((W - Sq) / (B - Sq)) <= .01
               then 0
               else Double.NaN;
     Squeeze.SetStyle(Curve.POINTS);
     Squeeze.SetLineWeight(3);
     Squeeze.SetDefaultColor(Color.YELLOW);
AddLabel(Squeeze, "Squeeze", Color.YELLOW);
plot "0" = if !IsNaN(Squeeze) or IsNaN(c) then Double.NaN else 0;
     "0".SetStyle(Curve.Points);
     "0".SetDefaultColor(Color.GRAY);
plot "1" = if IsNaN(c) then Double.NaN else 1;
     "1".SetDefaultColor(Color.GREEN);
plot "-1" = if IsNaN(c) then Double.NaN else -1;
     "-1".SetDefaultColor(Color.dark_RED);
# End Code V02 Momentum Squeeze
@Jonas99 shared this on Discord. He provided this image with the comparison of the indicator which is the one on the very bottom.
Hi @MerryDay or anyone else, can you explain how these original code variables map to this newer codes variables:

Original Code:
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);
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


Newer Code: My guesses of old code (some obvious):
input n = 20; length
def c = close; price
def mean = Inertia(c, n); Avg
def SD = Sqrt((fold i = 0 to n SD
with s
do s + Sqr(mean - GetValue(c, i))) / n);
def upper = mean + (2 * SD); ? SDup with SdMult = 2
def lower = mean - (2 * SD); ? SDlow - not in original code
def W = (upper - lower) / mean;
def B = Highest(W, n * 2); ? ATRup with ATRmult = 2 (if so why change from 1.5 to 2)
def Sq = Lowest(W, n * 2); ? ATRlow - not in orginal
plot Squeeze = if ((W - Sq) / (B - Sq)) <= .01 ? Why now less than 0.1 vs if SDup < ATRup
? why no K
? if any '?' are wrong, what are they and how do they map, and why the change?

Thanks!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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