Multi Symbol Squeeze

KG3344

New member
Hello,
I am trying to code a multi-symbol squeeze, but am having trouble figuring out how to call a variable from a script. I posted the code below. Please excuse the script's messiness, been copying from a couple of different scripts. The error is the last line of code where it is assigning a color to the squeeze line. I am going to keep trying to figure it out, but any tips would be greatly appreciated.

Code:
declare lower;
input bbprice = close;
input displace = 0;
def Length = 20.0;
input numdevdn = -2.0;
input numdevup = 2.0;
input averagetype = AverageType.SIMPLE;

def bb_midline = BollingerBands(bbprice, displace, Length, numdevdn, numdevup, averagetype).MidLine;
def bb_upperband = BollingerBands(bbprice, displace, Length, numdevdn, numdevup, averagetype).UpperBand;
def bb_lowerband = BollingerBands(bbprice, displace, Length, numdevdn, numdevup, averagetype).LowerBand;


# Use reference calls to TOS KC's and plot midline and bands

input kcdisplace = 0;
input kcfactor = 1.5;
input kclength = 20;
input kcprice = close;
input kcaverageType = AverageType.SIMPLE;
input kctrueRangeAverageType = AverageType.SIMPLE;

def kc_midline = KeltnerChannels(kcdisplace, kcfactor, kclength, kcprice, kcaverageType, kctrueRangeAverageType).Avg;
def kc_upperband = KeltnerChannels(kcdisplace, kcfactor, kclength, kcprice, kcaverageType, kctrueRangeAverageType).Upper_Band;
def kc_lowerband = KeltnerChannels(kcdisplace, kcfactor, kclength, kcprice, kcaverageType, kctrueRangeAverageType).Lower_Band;


# When the BB upper and lower bands cross inside the KC's we are in a Squeeze

input symbol10 = "XLY";
input symbol9 = "XLP";
input symbol8 = "XLE";
input symbol7 = "XLF";
input symbol6 = "XLV";
input symbol5 = "XLI";
input symbol4 = "XLB";
input symbol3 = "XLRE";
input symbol2 = "XLK";
input symbol1 = "XLU";


def nBB = 2.0;

def nK_High = 1.0;
def nK_Mid = 1.5;
def nK_Low = 2.0;
def price = close;

script SymbolSqueeze {
    input symbol = "";
    def nBB = 2.0;
    def Length = 20.0;
    def nK_High = 1.0;
    def nK_Mid = 1.5;
    def nK_Low = 2.0;
    def price = close(symbol);
    def bbprice = close(symbol);
    input displace = 0;

    input numdevdn = -2.0;
    input numdevup = 2.0;
    input averagetype = AverageType.SIMPLE;

    def bb_midline = BollingerBands(price, displace, Length, numdevdn, numdevup, averagetype).MidLine;
    def bb_upperband = BollingerBands(price, displace, Length, numdevdn, numdevup, averagetype).UpperBand;
    def bb_lowerband = BollingerBands(price, displace, Length, numdevdn, numdevup, averagetype).LowerBand;


# Use reference calls to TOS KC's and plot midline and bands

    input kcdisplace = 0;
    input kcfactor = 1.5;
    input kclength = 20;
    def kcprice = close(symbol);
    input kcaverageType = AverageType.SIMPLE;
    input kctrueRangeAverageType = AverageType.SIMPLE;

    def kc_midline = KeltnerChannels(kcdisplace, kcfactor, kclength, kcprice, kcaverageType, kctrueRangeAverageType).Avg;
    def kc_upperband = KeltnerChannels(kcdisplace, kcfactor, kclength, kcprice, kcaverageType, kctrueRangeAverageType).Upper_Band;
    def kc_lowerband = KeltnerChannels(kcdisplace, kcfactor, kclength, kcprice, kcaverageType, kctrueRangeAverageType).Lower_Band;


# When the BB upper and lower bands cross inside the KC's we are in a Squeeze

    def squeezed = if bb_upperband <= kc_upperband and bb_lowerband >= kc_lowerband then 1 else if bb_upperband >= kc_upperband and bb_lowerband <= kc_lowerband then -1 else 0;
    plot squeezed2 = If(IsNaN(price), Double.NaN, 0);

}

#plot squeeze = If(IsNaN(close), Double.NaN, 0);

#squeeze.DefineColor("NoSqueeze", Color.GREEN);
#squeeze.DefineColor("SqueezeLow", Color.black);
#squeeze.DefineColor("SqueezeMid", Color.RED);
#squeeze.DefineColor("SqueezeHigh", Color.orange);
#squeeze.AssignValueColor(if BolKelDelta_High <= 0 then squeeze.Color("SqueezeHigh") #else if BolKelDelta_Mid <= 0 then squeeze.Color("SqueezeMid") else if #BolKelDelta_Low <= 0 then squeeze.Color("SqueezeLow") else #squeeze.color("noSqueeze"));
#squeeze.SetPaintingStrategy(PaintingStrategy.POINTS);
#squeeze.SetLineWeight(3);
def s1 = SymbolSqueeze(symbol1);
def s2 = SymbolSqueeze(symbol2);
def s3 = SymbolSqueeze(symbol3);
def s4 = SymbolSqueeze(symbol4);
def s5 = SymbolSqueeze(symbol5);
def s6 = SymbolSqueeze(symbol6);
def s7 = SymbolSqueeze(symbol7);
def s8 = SymbolSqueeze(symbol8);
def s9 = SymbolSqueeze(symbol9);
def s10 = SymbolSqueeze(symbol10);

plot symb2 = if !IsNaN(close) and !IsNaN(close(symbol2)) then 2 else Double.NaN;
symb2.DefineColor("NoSqueeze", Color.GREEN);
symb2.DefineColor("SqueezeLow", Color.BLACK);
symb2.DefineColor("SqueezeMid", Color.RED);
symb2.DefineColor("SqueezeHigh", Color.ORANGE);

symb2.SetLineWeight(3);


symb2.AssignValueColor(if squeezed >= 0 then symb2.Color("SqueezeMid") else symb2.Color("noSqueeze"));
symb2.SetPaintingStrategy(PaintingStrategy.POINTS);
 
Solution
i started with kg3344 code from post #11 and made some changes.
the changes are listed in comments at the top of the study
the bubble colors change to match the last dot.

EDIT: reword this sentence
this is why the bubble colors were not changing,
the bubbles are shifted, 2 and 5 bars, after the last bar, but the color trigger variable was not offset.

Ruby:
# sqz10symbols_01

# https://usethinkscript.com/threads/multi-symbol-squeeze.6924/
# Multi Symbol Squeeze

# ------------------
# mods by halcyonguy
#  started with kg3344 code from post #11
# ------------------
# bubbles are shifted, 2 and 5 bars, after the last bar, but color trigger is not.
#  the s# var needs to be shifted also
#  add variables for the 2 time shifts, for...
Can anyone write the squeeze code so the lower indicator will show up to 5 stock/etf and weather they are in a squeeze.
Example: looking at spy (30 minutes) on upper
And on lower it displays xlv, xlk etc…30 minutes and whether they are in a squeeze
see my make shift work around
how do you do the workaround on tos as per your attach photo
 

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

@SleepyZ ... any chance to expand your code above to include the Squeeze Pro parameters where the "nK" variable is 1.0 for High compression, 1.5 for Med compression, and 2.0 for Low compression? And then choose the "Dot color" for Low compression as Black? Would very much appreciate that!! Thanx in advance.
 
Could use some help with creating "BUBBLES" along the right edge of the chart.
This TOS link (https://tos.mx/RT8qWgJ) has the Squeeze Pro code for multiple symbols showing up as "Dots" for High, Med, and Low compression. Can't seem to get rid of the excess dots on the right and then to create the appropriate labels. The code was modified from useThinkScript code from several different sources. Appreciate any and all assistance. Thanx in advance.
1711808972277.png
 
@halcyonguy ... my apologies for the confusion over the weekend with asking about the Multi-Symbol squeeze formatting ... and a lack of identifying the thread. I'm relatively new at this.
But here is what I'm trying to solve. The first screen shot below shows the Bubble to the right of the chart ... color coded to the last squeeze in the timeframe. What I've attempted to do was add the Squeeze Pro parameters (high, med, low compression) which is shown in the second screenshot below where there is a continuation of "dots". I am trying several approaches to remove the dot and add the Bubble with the symbol (as noted in the above chart). I believe the thread above is where most of the discussion started.
I made some slight modifications on KG3344's code (above) and it can be found in the tos link ... https://tos.mx/g04YPJN. Any help would be most appreciated. And I'll keep plugging away to see if I can fix it myself. Again, sorry for the confusion.
1711970865910.png

1711970893714.png
 
@halcyonguy ... my apologies for the confusion over the weekend with asking about the Multi-Symbol squeeze formatting ... and a lack of identifying the thread. I'm relatively new at this.
But here is what I'm trying to solve. The first screen shot below shows the Bubble to the right of the chart ... color coded to the last squeeze in the timeframe. What I've attempted to do was add the Squeeze Pro parameters (high, med, low compression) which is shown in the second screenshot below where there is a continuation of "dots". I am trying several approaches to remove the dot and add the Bubble with the symbol (as noted in the above chart). I believe the thread above is where most of the discussion started.
I made some slight modifications on KG3344's code (above) and it can be found in the tos link ... https://tos.mx/g04YPJN. Any help would be most appreciated. And I'll keep plugging away to see if I can fix it myself. Again, sorry for the confusion.
View attachment 21485
View attachment 21486

1. Removed isnan(close) area in expansion.
2. Added color coded, movable bubbles in expansion.
3. Added spacers for bubbles to keep them in view

Screenshot 2024-04-02 103903.png
Code:
#Doug_SqzPro_MultiSymbol_v3

declare lower;

##### Bubbles
input showbubbles = yes;
input bubblemover = 4;
input bubble_updown = {default up, down};

def bm  = bubblemover;
def bm1 = bm + 1;
def last = IsNaN(close[bm]) and !IsNaN(close[bm1]);
def mover = showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]);

def na = Double.NaN;

plot top_spacer = 170;
top_spacer.SetDefaultColor(Color.BLACK);
top_spacer.HideBubble();

plot bot_spacer = -20;
bot_spacer.SetDefaultColor(Color.BLACK);
bot_spacer.HideBubble();
#########

def over_bought0 = -10;
plot OverBought0 = if IsNaN(close) then na else over_bought0;
OverBought0.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought0.SetStyle(Curve.LONG_DASH);
OverBought0.SetLineWeight(3);

def over_bought = 0;
plot OverBought = if IsNaN(close) then na else over_bought;
OverBought.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought.SetStyle(Curve.LONG_DASH);
OverBought.SetLineWeight(3);

def over_bought1 = 10;
plot OverBought1 = if IsNaN(close) then na else over_bought1;
OverBought1.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought1.SetStyle(Curve.LONG_DASH);
OverBought1.SetLineWeight(3);


def over_bought2 = 20;
plot OverBought2 = if IsNaN(close) then na else over_bought2;
OverBought2.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought2.SetStyle(Curve.LONG_DASH);
OverBought2.SetLineWeight(3);

def over_bought3 = 30;
plot OverBought3 = if IsNaN(close) then na else over_bought3;
OverBought3.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought3.SetStyle(Curve.LONG_DASH);
OverBought3.SetLineWeight(3);


def over_bought4 = 40;
plot OverBought4 = if IsNaN(close) then na else over_bought4;
OverBought4.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought4.SetStyle(Curve.LONG_DASH);
OverBought4.SetLineWeight(3);


def over_bought5 = 50;
plot OverBought5 = if IsNaN(close) then na else over_bought5;
OverBought5.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought5.SetStyle(Curve.LONG_DASH);
OverBought5.SetLineWeight(3);


def over_bought6 = 60;
plot OverBought6 = if IsNaN(close) then na else over_bought6;
OverBought6.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought6.SetStyle(Curve.LONG_DASH);
OverBought6.SetLineWeight(3);


def over_bought7 = 70;
plot OverBought7 = if IsNaN(close) then na else over_bought7;
OverBought7.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought7.SetStyle(Curve.LONG_DASH);
OverBought7.SetLineWeight(3);


def over_bought8 = 80;
plot OverBought8 = if IsNaN(close) then na else over_bought8;
OverBought8.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought8.SetStyle(Curve.LONG_DASH);
OverBought8.SetLineWeight(3);


def over_bought9 = 90;
plot OverBought9 = if IsNaN(close) then na else over_bought9;
OverBought9.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought9.SetStyle(Curve.LONG_DASH);
OverBought9.SetLineWeight(3);


def over_bought10 = 100;
plot OverBought10 = if IsNaN(close) then na else over_bought10;
OverBought10.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought10.SetStyle(Curve.LONG_DASH);
OverBought10.SetLineWeight(3);

def over_bought11 = 110;
plot OverBought11 = if IsNaN(close) then na else over_bought11;
OverBought11.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought11.SetStyle(Curve.LONG_DASH);
OverBought11.SetLineWeight(3);


def over_bought12 = 120;
plot OverBought12 = if IsNaN(close) then na else over_bought12;
OverBought12.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought12.SetStyle(Curve.LONG_DASH);
OverBought12.SetLineWeight(3);

def over_bought13 = 130;
plot OverBought13 = if IsNaN(close) then na else over_bought13;
OverBought13.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought13.SetStyle(Curve.LONG_DASH);
OverBought13.SetLineWeight(3);


def over_bought14 = 140;
plot OverBought14 = if IsNaN(close) then na else over_bought14;
OverBought14.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought14.SetStyle(Curve.LONG_DASH);
OverBought14.SetLineWeight(3);

def over_bought15 = 150;
plot OverBought15 = if IsNaN(close) then na else over_bought15;
OverBought15.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought15.SetStyle(Curve.LONG_DASH);
OverBought15.SetLineWeight(3);

def over_bought16 = 160;
plot OverBought16 = if IsNaN(close) then na else over_bought16;
OverBought16.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
OverBought16.SetStyle(Curve.LONG_DASH);
OverBought16.SetLineWeight(3);


input symbol0 = "DIA";
input symbol = "SPY";
input symbol1 = "QQQ";
input symbol2 = "IWM";
input symbol3 = "XLB";
input symbol4 = "XLC";
input symbol5 = "XLE";
input symbol6 = "XLF";
input symbol7 = "XLI";
input symbol8 = "XLK";
input symbol9 = "XLP";
input symbol10 = "XLU";
input symbol11 = "XLV";
input symbol12 = "XLY";
input symbol13 = "XRT";
input symbol14 = "XHB";
input symbol15 = "IYT";
input symbol16 = "VIX";

def length = 20;
def Num_Dev_Dn = -2.0;
def Num_Dev_up = 2.0;
def averageType = AverageType.SIMPLE;
def factorhigh = 1.0;
def factormid = 1.5;
def factorlow = 2.0;
def trueRangeAverageType = AverageType.SIMPLE;


#def displace = 0;
def sDev0 = StDev(data = close(symbol0), length = length);
def MidLineBB0 = MovingAverage(averageType, data = close(symbol0), length = length);
def LowerBand0BB0 = MidLineBB0 + Num_Dev_Dn * sDev0;
def UpperBand0BB0 = MidLineBB0 + Num_Dev_up * sDev0;

def shift0high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol0), close(symbol0), low(symbol0)), length);
def shift0Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol0), close(symbol0), low(symbol0)), length);
def shift0low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol0), close(symbol0), low(symbol0)), length);
def average0 = MovingAverage(averageType, close(symbol0), length);

def Avg0 = average0;

def UpperBand0KCLow = average0 + shift0low;
def LowerBand0KCLow = average0 - shift0low;

def UpperBand0KCMid = average0 + shift0Mid;
def LowerBand0KCMid = average0 - shift0Mid;
def UpperBand0KCHigh = average0 + shift0high;
def LowerBand0KCHigh = average0 - shift0high;

def preSqueeze0 = LowerBand0BB0 > LowerBand0KCLow and UpperBand0BB0 < UpperBand0KCLow;
def originalSqueeze0 = LowerBand0BB0 > LowerBand0KCMid and UpperBand0BB0 < UpperBand0KCMid;
def ExtrSqueeze0 = LowerBand0BB0 > LowerBand0KCHigh and UpperBand0BB0 < UpperBand0KCHigh;

OverBought0.AssignValueColor(if ExtrSqueeze0 then Color.ORANGE else if originalSqueeze0 then Color.RED else if preSqueeze0 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol0, if ExtrSqueeze0 then Color.ORANGE else if originalSqueeze0 then Color.RED else if preSqueeze0 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought0[bm1], symbol0, if ExtrSqueeze0[bm1] then Color.ORANGE else if originalSqueeze0[bm1] then Color.RED else if preSqueeze0[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);


##########SPY
def sDev = StDev(data = close(symbol), length = length);
def MidLineBB = MovingAverage(averageType, data = close(symbol), length = length);
def LowerBandBB = MidLineBB + Num_Dev_Dn * sDev;
def UpperBandBB = MidLineBB + Num_Dev_up * sDev;

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


def Avg = average;

def UpperBandKCLow = average + shiftlow;
def LowerBandKCLow = average - shiftlow;

def UpperBandKCMid = average + shiftMid;
def LowerBandKCMid = average - shiftMid;

def UpperBandKCHigh = average + shifthigh;
def LowerBandKCHigh = average - shifthigh;


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

OverBought.AssignValueColor(if ExtrSqueeze then Color.ORANGE else if originalSqueeze then Color.RED else if presqueeze then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol, if ExtrSqueeze then Color.ORANGE else if originalSqueeze then Color.RED else if presqueeze then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought[bm1], symbol, if ExtrSqueeze[bm1] then Color.ORANGE else if originalSqueeze[bm1] then Color.RED else if presqueeze[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);



def sDev1 = StDev(data = close(symbol1), length = length);
def MidLineBB1 = MovingAverage(averageType, data = close(symbol1), length = length);
def LowerBand1BB1 = MidLineBB1 + Num_Dev_Dn * sDev1;
def UpperBand1BB1 = MidLineBB1 + Num_Dev_up * sDev1;

def shift1high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol1), close(symbol1), low(symbol1)), length);
def shift1Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol1), close(symbol1), low(symbol1)), length);
def shift1low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol1), close(symbol1), low(symbol1)), length);
def average1 = MovingAverage(averageType, close(symbol1), length);

def Avg1 = average1;

def UpperBand1KCLow = average1 + shift1low;
def LowerBand1KCLow = average1 - shift1low;

def UpperBand1KCMid = average1 + shift1Mid;
def LowerBand1KCMid = average1 - shift1Mid;
def UpperBand1KCHigh = average1 + shift1high;
def LowerBand1KCHigh = average1 - shift1high;

def preSqueeze1 = LowerBand1BB1 > LowerBand1KCLow and UpperBand1BB1 < UpperBand1KCLow;
def originalSqueeze1 = LowerBand1BB1 > LowerBand1KCMid and UpperBand1BB1 < UpperBand1KCMid;
def ExtrSqueeze1 = LowerBand1BB1 > LowerBand1KCHigh and UpperBand1BB1 < UpperBand1KCHigh;

OverBought1.AssignValueColor(if ExtrSqueeze1 then Color.ORANGE else if originalSqueeze1 then Color.RED else if preSqueeze1 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol1, if ExtrSqueeze1 then Color.ORANGE else if originalSqueeze1 then Color.RED else if preSqueeze1 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought1[bm1], symbol1, if ExtrSqueeze1[bm1] then Color.ORANGE else if originalSqueeze1[bm1] then Color.RED else if preSqueeze1[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);



def sDev2 = StDev(data = close(symbol2), length = length);
def MidLineBB2 = MovingAverage(averageType, data = close(symbol2), length = length);
def LowerBand2BB2 = MidLineBB2 + Num_Dev_Dn * sDev2;
def UpperBand2BB2 = MidLineBB2 + Num_Dev_up * sDev2;

def shift2high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol2), close(symbol2), low(symbol2)), length);
def shift2Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol2), close(symbol2), low(symbol2)), length);
def shift2low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol2), close(symbol2), low(symbol2)), length);
def average2 = MovingAverage(averageType, close(symbol2), length);

def Avg2 = average2;

def UpperBand2KCLow = average2 + shift2low;
def LowerBand2KCLow = average2 - shift2low;

def UpperBand2KCMid = average2 + shift2Mid;
def LowerBand2KCMid = average2 - shift2Mid;
def UpperBand2KCHigh = average2 + shift2high;
def LowerBand2KCHigh = average2 - shift2high;

def preSqueeze2 = LowerBand2BB2 > LowerBand2KCLow and UpperBand2BB2 < UpperBand2KCLow;
def originalSqueeze2 = LowerBand2BB2 > LowerBand2KCMid and UpperBand2BB2 < UpperBand2KCMid;
def ExtrSqueeze2 = LowerBand2BB2 > LowerBand2KCHigh and UpperBand2BB2 < UpperBand2KCHigh;

OverBought2.AssignValueColor(if ExtrSqueeze2 then Color.ORANGE else if originalSqueeze2 then Color.RED else if preSqueeze2 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol2, if ExtrSqueeze2 then Color.ORANGE else if originalSqueeze2 then Color.RED else if preSqueeze2 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought2[bm1], symbol2, if ExtrSqueeze2[bm1] then Color.ORANGE else if originalSqueeze2[bm1] then Color.RED else if preSqueeze2[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);



def sDev3 = StDev(data = close(symbol3), length = length);
def MidLineBB3 = MovingAverage(averageType, data = close(symbol3), length = length);
def LowerBand3BB3 = MidLineBB3 + Num_Dev_Dn * sDev3;
def UpperBand3BB3 = MidLineBB3 + Num_Dev_up * sDev3;

def shift3high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol3), close(symbol3), low(symbol3)), length);
def shift3Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol3), close(symbol3), low(symbol3)), length);
def shift3low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol3), close(symbol3), low(symbol3)), length);
def average3 = MovingAverage(averageType, close(symbol3), length);

def Avg3 = average3;

def UpperBand3KCLow = average3 + shift3low;
def LowerBand3KCLow = average3 - shift3low;

def UpperBand3KCMid = average3 + shift3Mid;
def LowerBand3KCMid = average3 - shift3Mid;
def UpperBand3KCHigh = average3 + shift3high;
def LowerBand3KCHigh = average3 - shift3high;

def preSqueeze3 = LowerBand3BB3 > LowerBand3KCLow and UpperBand3BB3 < UpperBand3KCLow;
def originalSqueeze3 = LowerBand3BB3 > LowerBand3KCMid and UpperBand3BB3 < UpperBand3KCMid;
def ExtrSqueeze3 = LowerBand3BB3 > LowerBand3KCHigh and UpperBand3BB3 < UpperBand3KCHigh;

OverBought3.AssignValueColor(if ExtrSqueeze3 then Color.ORANGE else if originalSqueeze3 then Color.RED else if preSqueeze3 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol3, if ExtrSqueeze3 then Color.ORANGE else if originalSqueeze3 then Color.RED else if preSqueeze3 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought3[bm1], symbol3, if ExtrSqueeze3[bm1] then Color.ORANGE else if originalSqueeze3[bm1] then Color.RED else if preSqueeze3[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);



def sDev4 = StDev(data = close(symbol4), length = length);
def MidLineBB4 = MovingAverage(averageType, data = close(symbol4), length = length);
def LowerBand4BB4 = MidLineBB4 + Num_Dev_Dn * sDev4;
def UpperBand4BB4 = MidLineBB4 + Num_Dev_up * sDev4;

def shift4high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol4), close(symbol4), low(symbol4)), length);
def shift4Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol4), close(symbol4), low(symbol4)), length);
def shift4low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol4), close(symbol4), low(symbol4)), length);
def average4 = MovingAverage(averageType, close(symbol4), length);

def Avg4 = average4;

def UpperBand4KCLow = average4 + shift4low;
def LowerBand4KCLow = average4 - shift4low;

def UpperBand4KCMid = average4 + shift4Mid;
def LowerBand4KCMid = average4 - shift4Mid;
def UpperBand4KCHigh = average4 + shift4high;
def LowerBand4KCHigh = average4 - shift4high;

def preSqueeze4 = LowerBand4BB4 > LowerBand4KCLow and UpperBand4BB4 < UpperBand4KCLow;
def originalSqueeze4 = LowerBand4BB4 > LowerBand4KCMid and UpperBand4BB4 < UpperBand4KCMid;
def ExtrSqueeze4 = LowerBand4BB4 > LowerBand4KCHigh and UpperBand4BB4 < UpperBand4KCHigh;

OverBought4.AssignValueColor(if ExtrSqueeze4 then Color.ORANGE else if originalSqueeze4 then Color.RED else if preSqueeze4 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol4, if ExtrSqueeze4 then Color.ORANGE else if originalSqueeze4 then Color.RED else if preSqueeze4 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought4[bm1], symbol4, if ExtrSqueeze4[bm1] then Color.ORANGE else if originalSqueeze4[bm1] then Color.RED else if preSqueeze4[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);



def sDev5 = StDev(data = close(symbol5), length = length);
def MidLineBB5 = MovingAverage(averageType, data = close(symbol5), length = length);
def LowerBand5BB5 = MidLineBB5 + Num_Dev_Dn * sDev5;
def UpperBand5BB5 = MidLineBB5 + Num_Dev_up * sDev5;

def shift5high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol5), close(symbol5), low(symbol5)), length);
def shift5Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol5), close(symbol5), low(symbol5)), length);
def shift5low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol5), close(symbol5), low(symbol5)), length);
def average5 = MovingAverage(averageType, close(symbol5), length);

def Avg5 = average5;

def UpperBand5KCLow = average5 + shift5low;
def LowerBand5KCLow = average5 - shift5low;

def UpperBand5KCMid = average5 + shift5Mid;
def LowerBand5KCMid = average5 - shift5Mid;
def UpperBand5KCHigh = average5 + shift5high;
def LowerBand5KCHigh = average5 - shift5high;

def preSqueeze5 = LowerBand5BB5 > LowerBand5KCLow and UpperBand5BB5 < UpperBand5KCLow;
def originalSqueeze5 = LowerBand5BB5 > LowerBand5KCMid and UpperBand5BB5 < UpperBand5KCMid;
def ExtrSqueeze5 = LowerBand5BB5 > LowerBand5KCHigh and UpperBand5BB5 < UpperBand5KCHigh;

OverBought5.AssignValueColor(if ExtrSqueeze5 then Color.ORANGE else if originalSqueeze5 then Color.RED else if preSqueeze5 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol5, if ExtrSqueeze5 then Color.ORANGE else if originalSqueeze5 then Color.RED else if preSqueeze5 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought5[bm1], symbol5, if ExtrSqueeze5[bm1] then Color.ORANGE else if originalSqueeze5[bm1] then Color.RED else if preSqueeze5[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);



def sDev6 = StDev(data = close(symbol6), length = length);
def MidLineBB6 = MovingAverage(averageType, data = close(symbol6), length = length);
def LowerBand6BB6 = MidLineBB6 + Num_Dev_Dn * sDev6;
def UpperBand6BB6 = MidLineBB6 + Num_Dev_up * sDev6;

def shift6high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol6), close(symbol6), low(symbol6)), length);
def shift6Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol6), close(symbol6), low(symbol6)), length);
def shift6low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol6), close(symbol6), low(symbol6)), length);
def average6 = MovingAverage(averageType, close(symbol6), length);

def Avg6 = average6;

def UpperBand6KCLow = average6 + shift6low;
def LowerBand6KCLow = average6 - shift6low;

def UpperBand6KCMid = average6 + shift6Mid;
def LowerBand6KCMid = average6 - shift6Mid;
def UpperBand6KCHigh = average6 + shift6high;
def LowerBand6KCHigh = average6 - shift6high;

def preSqueeze6 = LowerBand6BB6 > LowerBand6KCLow and UpperBand6BB6 < UpperBand6KCLow;
def originalSqueeze6 = LowerBand6BB6 > LowerBand6KCMid and UpperBand6BB6 < UpperBand6KCMid;
def ExtrSqueeze6 = LowerBand6BB6 > LowerBand6KCHigh and UpperBand6BB6 < UpperBand6KCHigh;

OverBought6.AssignValueColor(if ExtrSqueeze6 then Color.ORANGE else if originalSqueeze6 then Color.RED else if preSqueeze6 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol6, if ExtrSqueeze6 then Color.ORANGE else if originalSqueeze6 then Color.RED else if preSqueeze6 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought6[bm1], symbol6, if ExtrSqueeze6[bm1] then Color.ORANGE else if originalSqueeze6[bm1] then Color.RED else if preSqueeze6[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);


def sDev7 = StDev(data = close(symbol7), length = length);
def MidLineBB7 = MovingAverage(averageType, data = close(symbol7), length = length);
def LowerBand7BB7 = MidLineBB7 + Num_Dev_Dn * sDev7;
def UpperBand7BB7 = MidLineBB7 + Num_Dev_up * sDev7;

def shift7high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol7), close(symbol7), low(symbol7)), length);
def shift7Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol7), close(symbol7), low(symbol7)), length);
def shift7low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol7), close(symbol7), low(symbol7)), length);
def average7 = MovingAverage(averageType, close(symbol7), length);

def Avg7 = average7;

def UpperBand7KCLow = average7 + shift7low;
def LowerBand7KCLow = average7 - shift7low;

def UpperBand7KCMid = average7 + shift7Mid;
def LowerBand7KCMid = average7 - shift7Mid;
def UpperBand7KCHigh = average7 + shift7high;
def LowerBand7KCHigh = average7 - shift7high;

def preSqueeze7 = LowerBand7BB7 > LowerBand7KCLow and UpperBand7BB7 < UpperBand7KCLow;
def originalSqueeze7 = LowerBand7BB7 > LowerBand7KCMid and UpperBand7BB7 < UpperBand7KCMid;
def ExtrSqueeze7 = LowerBand7BB7 > LowerBand7KCHigh and UpperBand7BB7 < UpperBand7KCHigh;

OverBought7.AssignValueColor(if ExtrSqueeze7 then Color.ORANGE else if originalSqueeze7 then Color.RED else if preSqueeze7 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol7, if ExtrSqueeze7 then Color.ORANGE else if originalSqueeze7 then Color.RED else if preSqueeze7 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought7[bm1], symbol, if ExtrSqueeze7[bm1] then Color.ORANGE else if originalSqueeze7[bm1] then Color.RED else if preSqueeze7[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);


def sDev8 = StDev(data = close(symbol8), length = length);
def MidLineBB8 = MovingAverage(averageType, data = close(symbol8), length = length);
def LowerBand8BB8 = MidLineBB8 + Num_Dev_Dn * sDev8;
def UpperBand8BB8 = MidLineBB8 + Num_Dev_up * sDev8;

def shift8high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol8), close(symbol8), low(symbol8)), length);
def shift8Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol8), close(symbol8), low(symbol8)), length);
def shift8low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol8), close(symbol8), low(symbol8)), length);
def average8 = MovingAverage(averageType, close(symbol8), length);

def Avg8 = average8;

def UpperBand8KCLow = average8 + shift8low;
def LowerBand8KCLow = average8 - shift8low;

def UpperBand8KCMid = average8 + shift8Mid;
def LowerBand8KCMid = average8 - shift8Mid;
def UpperBand8KCHigh = average8 + shift8high;
def LowerBand8KCHigh = average8 - shift8high;

def preSqueeze8 = LowerBand8BB8 > LowerBand8KCLow and UpperBand8BB8 < UpperBand8KCLow;
def originalSqueeze8 = LowerBand8BB8 > LowerBand8KCMid and UpperBand8BB8 < UpperBand8KCMid;
def ExtrSqueeze8 = LowerBand8BB8 > LowerBand8KCHigh and UpperBand8BB8 < UpperBand8KCHigh;

OverBought8.AssignValueColor(if ExtrSqueeze8 then Color.ORANGE else if originalSqueeze8 then Color.RED else if preSqueeze8 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol8, if ExtrSqueeze8 then Color.ORANGE else if originalSqueeze8 then Color.RED else if preSqueeze8 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought8[bm1], symbol8, if ExtrSqueeze8[bm1] then Color.ORANGE else if originalSqueeze8[bm1] then Color.RED else if preSqueeze8[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);


def sDev9 = StDev(data = close(symbol9), length = length);
def MidLineBB9 = MovingAverage(averageType, data = close(symbol9), length = length);
def LowerBand9BB9 = MidLineBB9 + Num_Dev_Dn * sDev9;
def UpperBand9BB9 = MidLineBB9 + Num_Dev_up * sDev9;

def shift9high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol9), close(symbol9), low(symbol9)), length);
def shift9Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol9), close(symbol9), low(symbol9)), length);
def shift9low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol9), close(symbol9), low(symbol9)), length);
def average9 = MovingAverage(averageType, close(symbol9), length);

def Avg9 = average9;

def UpperBand9KCLow = average9 + shift9low;
def LowerBand9KCLow = average9 - shift9low;

def UpperBand9KCMid = average9 + shift9Mid;
def LowerBand9KCMid = average9 - shift9Mid;
def UpperBand9KCHigh = average9 + shift9high;
def LowerBand9KCHigh = average9 - shift9high;

def preSqueeze9 = LowerBand9BB9 > LowerBand9KCLow and UpperBand9BB9 < UpperBand9KCLow;
def originalSqueeze9 = LowerBand9BB9 > LowerBand9KCMid and UpperBand9BB9 < UpperBand9KCMid;
def ExtrSqueeze9 = LowerBand9BB9 > LowerBand9KCHigh and UpperBand9BB9 < UpperBand9KCHigh;

OverBought9.AssignValueColor(if ExtrSqueeze9 then Color.ORANGE else if originalSqueeze9 then Color.RED else if preSqueeze9 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol9, if ExtrSqueeze9 then Color.ORANGE else if originalSqueeze9 then Color.RED else if preSqueeze9 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought9[bm1], symbol, if ExtrSqueeze9[bm1] then Color.ORANGE else if originalSqueeze9[bm1] then Color.RED else if preSqueeze9[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);



def sDev10 = StDev(data = close(symbol10), length = length);
def MidLineBB10 = MovingAverage(averageType, data = close(symbol10), length = length);
def LowerBand10BB10 = MidLineBB10 + Num_Dev_Dn * sDev10;
def UpperBand10BB10 = MidLineBB10 + Num_Dev_up * sDev10;

def shift10high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol10), close(symbol10), low(symbol10)), length);
def shift10Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol10), close(symbol10), low(symbol10)), length);
def shift10low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol10), close(symbol10), low(symbol10)), length);
def average10 = MovingAverage(averageType, close(symbol10), length);

def Avg10 = average10;

def UpperBand10KCLow = average10 + shift10low;
def LowerBand10KCLow = average10 - shift10low;

def UpperBand10KCMid = average10 + shift10Mid;
def LowerBand10KCMid = average10 - shift10Mid;
def UpperBand10KCHigh = average10 + shift10high;
def LowerBand10KCHigh = average10 - shift10high;

def preSqueeze10 = LowerBand10BB10 > LowerBand10KCLow and UpperBand10BB10 < UpperBand10KCLow;
def originalSqueeze10 = LowerBand10BB10 > LowerBand10KCMid and UpperBand10BB10 < UpperBand10KCMid;
def ExtrSqueeze10 = LowerBand10BB10 > LowerBand10KCHigh and UpperBand10BB10 < UpperBand10KCHigh;

OverBought10.AssignValueColor(if ExtrSqueeze10 then Color.ORANGE else if originalSqueeze10 then Color.RED else if preSqueeze10 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol10, if ExtrSqueeze10 then Color.ORANGE else if originalSqueeze10 then Color.RED else if preSqueeze10 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought10[bm1], symbol10, if ExtrSqueeze10[bm1] then Color.ORANGE else if originalSqueeze10[bm1] then Color.RED else if preSqueeze10[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);


def sDev11 = StDev(data = close(symbol11), length = length);
def MidLineBB11 = MovingAverage(averageType, data = close(symbol11), length = length);
def LowerBand11BB11 = MidLineBB11 + Num_Dev_Dn * sDev11;
def UpperBand11BB11 = MidLineBB11 + Num_Dev_up * sDev11;

def shift11high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol11), close(symbol11), low(symbol11)), length);
def shift11Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol11), close(symbol11), low(symbol11)), length);
def shift11low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol11), close(symbol11), low(symbol11)), length);
def average11 = MovingAverage(averageType, close(symbol11), length);

def Avg11 = average11;

def UpperBand11KCLow = average11 + shift11low;
def LowerBand11KCLow = average11 - shift11low;

def UpperBand11KCMid = average11 + shift11Mid;
def LowerBand11KCMid = average11 - shift11Mid;
def UpperBand11KCHigh = average11 + shift11high;
def LowerBand11KCHigh = average11 - shift11high;

def preSqueeze11 = LowerBand11BB11 > LowerBand11KCLow and UpperBand11BB11 < UpperBand11KCLow;
def originalSqueeze11 = LowerBand11BB11 > LowerBand11KCMid and UpperBand11BB11 < UpperBand11KCMid;
def ExtrSqueeze11 = LowerBand11BB11 > LowerBand11KCHigh and UpperBand11BB11 < UpperBand11KCHigh;

OverBought11.AssignValueColor(if ExtrSqueeze11 then Color.ORANGE else if originalSqueeze11 then Color.RED else if preSqueeze11 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol1, if ExtrSqueeze11 then Color.ORANGE else if originalSqueeze11 then Color.RED else if preSqueeze11 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought11[bm1], symbol11, if ExtrSqueeze11[bm1] then Color.ORANGE else if originalSqueeze11[bm1] then Color.RED else if preSqueeze11[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);



def sDev12 = StDev(data = close(symbol12), length = length);
def MidLineBB12 = MovingAverage(averageType, data = close(symbol12), length = length);
def LowerBand12BB12 = MidLineBB12 + Num_Dev_Dn * sDev12;
def UpperBand12BB12 = MidLineBB12 + Num_Dev_up * sDev12;

def shift12high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol12), close(symbol12), low(symbol12)), length);
def shift12Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol12), close(symbol12), low(symbol12)), length);
def shift12low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol12), close(symbol12), low(symbol12)), length);
def average12 = MovingAverage(averageType, close(symbol12), length);

def Avg12 = average12;

def UpperBand12KCLow = average12 + shift12low;
def LowerBand12KCLow = average12 - shift12low;

def UpperBand12KCMid = average12 + shift12Mid;
def LowerBand12KCMid = average12 - shift12Mid;
def UpperBand12KCHigh = average12 + shift12high;
def LowerBand12KCHigh = average12 - shift12high;

def preSqueeze12 = LowerBand12BB12 > LowerBand12KCLow and UpperBand12BB12 < UpperBand12KCLow;
def originalSqueeze12 = LowerBand12BB12 > LowerBand12KCMid and UpperBand12BB12 < UpperBand12KCMid;
def ExtrSqueeze12 = LowerBand12BB12 > LowerBand12KCHigh and UpperBand12BB12 < UpperBand12KCHigh;

OverBought12.AssignValueColor(if ExtrSqueeze12 then Color.ORANGE else if originalSqueeze12 then Color.RED else if preSqueeze12 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol12, if ExtrSqueeze12 then Color.ORANGE else if originalSqueeze12 then Color.RED else if preSqueeze12 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought12[bm1], symbol12, if ExtrSqueeze12[bm1] then Color.ORANGE else if originalSqueeze12[bm1] then Color.RED else if preSqueeze12[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);


def sDev13 = StDev(data = close(symbol13), length = length);
def MidLineBB13 = MovingAverage(averageType, data = close(symbol13), length = length);
def LowerBand13BB13 = MidLineBB13 + Num_Dev_Dn * sDev13;
def UpperBand13BB13 = MidLineBB13 + Num_Dev_up * sDev13;

def shift13high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol13), close(symbol13), low(symbol13)), length);
def shift13Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol13), close(symbol13), low(symbol13)), length);
def shift13low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol13), close(symbol13), low(symbol13)), length);
def average13 = MovingAverage(averageType, close(symbol13), length);

def Avg13 = average13;

def UpperBand13KCLow = average13 + shift13low;
def LowerBand13KCLow = average13 - shift13low;

def UpperBand13KCMid = average13 + shift13Mid;
def LowerBand13KCMid = average13 - shift13Mid;
def UpperBand13KCHigh = average13 + shift13high;
def LowerBand13KCHigh = average13 - shift13high;

def preSqueeze13 = LowerBand13BB13 > LowerBand13KCLow and UpperBand13BB13 < UpperBand13KCLow;
def originalSqueeze13 = LowerBand13BB13 > LowerBand13KCMid and UpperBand13BB13 < UpperBand13KCMid;
def ExtrSqueeze13 = LowerBand13BB13 > LowerBand13KCHigh and UpperBand13BB13 < UpperBand13KCHigh;

OverBought13.AssignValueColor(if ExtrSqueeze13 then Color.ORANGE else if originalSqueeze13 then Color.RED else if preSqueeze13 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol13, if ExtrSqueeze13 then Color.ORANGE else if originalSqueeze13 then Color.RED else if preSqueeze13 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought13[bm1], symbol13, if ExtrSqueeze13[bm1] then Color.ORANGE else if originalSqueeze13[bm1] then Color.RED else if preSqueeze13[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);


def sDev14 = StDev(data = close(symbol14), length = length);
def MidLineBB14 = MovingAverage(averageType, data = close(symbol14), length = length);
def LowerBand14BB14 = MidLineBB14 + Num_Dev_Dn * sDev14;
def UpperBand14BB14 = MidLineBB14 + Num_Dev_up * sDev14;

def shift14high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol14), close(symbol14), low(symbol14)), length);
def shift14Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol14), close(symbol14), low(symbol14)), length);
def shift14low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol14), close(symbol14), low(symbol14)), length);
def average14 = MovingAverage(averageType, close(symbol14), length);

def Avg14 = average14;

def UpperBand14KCLow = average14 + shift14low;
def LowerBand14KCLow = average14 - shift14low;

def UpperBand14KCMid = average14 + shift14Mid;
def LowerBand14KCMid = average14 - shift14Mid;
def UpperBand14KCHigh = average14 + shift14high;
def LowerBand14KCHigh = average14 - shift14high;

def preSqueeze14 = LowerBand14BB14 > LowerBand14KCLow and UpperBand14BB14 < UpperBand14KCLow;
def originalSqueeze14 = LowerBand14BB14 > LowerBand14KCMid and UpperBand14BB14 < UpperBand14KCMid;
def ExtrSqueeze14 = LowerBand14BB14 > LowerBand14KCHigh and UpperBand14BB14 < UpperBand14KCHigh;

OverBought14.AssignValueColor(if ExtrSqueeze14 then Color.ORANGE else if originalSqueeze14 then Color.RED else if preSqueeze14 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol14, if ExtrSqueeze14 then Color.ORANGE else if originalSqueeze14 then Color.RED else if preSqueeze14 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought14[bm1], symbol14, if ExtrSqueeze14[bm1] then Color.ORANGE else if originalSqueeze14[bm1] then Color.RED else if preSqueeze14[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);


def sDev15 = StDev(data = close(symbol15), length = length);
def MidLineBB15 = MovingAverage(averageType, data = close(symbol15), length = length);
def LowerBand15BB15 = MidLineBB15 + Num_Dev_Dn * sDev15;
def UpperBand15BB15 = MidLineBB15 + Num_Dev_up * sDev15;

def shift15high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol15), close(symbol15), low(symbol15)), length);
def shift15Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol15), close(symbol15), low(symbol15)), length);
def shift15low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol15), close(symbol15), low(symbol15)), length);
def average15 = MovingAverage(averageType, close(symbol15), length);

def Avg15 = average15;

def UpperBand15KCLow = average15 + shift15low;
def LowerBand15KCLow = average15 - shift15low;

def UpperBand15KCMid = average15 + shift15Mid;
def LowerBand15KCMid = average15 - shift15Mid;
def UpperBand15KCHigh = average15 + shift15high;
def LowerBand15KCHigh = average15 - shift15high;

def preSqueeze15 = LowerBand15BB15 > LowerBand15KCLow and UpperBand15BB15 < UpperBand15KCLow;
def originalSqueeze15 = LowerBand15BB15 > LowerBand15KCMid and UpperBand15BB15 < UpperBand15KCMid;
def ExtrSqueeze15 = LowerBand15BB15 > LowerBand15KCHigh and UpperBand15BB15 < UpperBand15KCHigh;

OverBought15.AssignValueColor(if ExtrSqueeze15 then Color.ORANGE else if originalSqueeze15 then Color.RED else if preSqueeze15 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol15, if ExtrSqueeze15 then Color.ORANGE else if originalSqueeze15 then Color.RED else if preSqueeze15 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought15[bm1], symbol15, if ExtrSqueeze15[bm1] then Color.ORANGE else if originalSqueeze15[bm1] then Color.RED else if preSqueeze15[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);



def sDev16 = StDev(data = close(symbol16), length = length);
def MidLineBB16 = MovingAverage(averageType, data = close(symbol16), length = length);
def LowerBand16BB16 = MidLineBB16 + Num_Dev_Dn * sDev16;
def UpperBand16BB16 = MidLineBB16 + Num_Dev_up * sDev16;

def shift16high = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high(symbol16), close(symbol16), low(symbol16)), length);
def shift16Mid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high(symbol16), close(symbol16), low(symbol16)), length);
def shift16low = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high(symbol16), close(symbol16), low(symbol16)), length);
def average16 = MovingAverage(averageType, close(symbol16), length);

def Avg16 = average16;

def UpperBand16KCLow = average16 + shift16low;
def LowerBand16KCLow = average16 - shift16low;

def UpperBand16KCMid = average16 + shift16Mid;
def LowerBand16KCMid = average16 - shift16Mid;
def UpperBand16KCHigh = average16 + shift16high;
def LowerBand16KCHigh = average16 - shift16high;

def preSqueeze16 = LowerBand16BB16 > LowerBand16KCLow and UpperBand16BB16 < UpperBand16KCLow;
def originalSqueeze16 = LowerBand16BB16 > LowerBand16KCMid and UpperBand16BB16 < UpperBand16KCMid;
def ExtrSqueeze16 = LowerBand16BB16 > LowerBand16KCHigh and UpperBand16BB16 < UpperBand16KCHigh;

OverBought16.AssignValueColor(if ExtrSqueeze16 then Color.ORANGE else if originalSqueeze16 then Color.RED else if preSqueeze16 then Color.GRAY else Color.GREEN);
AddLabel(yes, symbol16, if ExtrSqueeze16 then Color.ORANGE else if originalSqueeze16 then Color.RED else if preSqueeze16 then Color.GRAY else Color.GREEN);

AddChartBubble(mover, OverBought16[bm1], symbol16, if ExtrSqueeze16[bm1] then Color.ORANGE else if originalSqueeze16[bm1] then Color.RED else if preSqueeze16[bm1] then Color.GRAY else Color.GREEN, if bubble_updown == bubble_updown.down then no else yes);


#Addchartbubble(showbubbles and last,symbol0(bm1), symbol0, if ExtrSqueeze0 then Color.ORANGE #else if originalSqueeze0 then Color.RED else if preSqueeze0 then Color.GRAY else Color.GREEN);
 
sorry to ask but can you use this squeeze for lower indicator. I don't know how to code




declare lower;

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

input price = close;
input length = 20;
input Num_Dev_Dn = -1.0;
input Num_Dev_up = 1.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 presqueeze = LowerBandBB > LowerBandKCLow and UpperBandBB < UpperBandKCLow;
def originalSqueeze = LowerBandBB > LowerBandKCMid and UpperBandBB < UpperBandKCMid;
def ExtrSqueeze = LowerBandBB > LowerBandKCHigh and UpperBandBB < UpperBandKCHigh;

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

plot squeezeline = 0;
squeezeline.SetPaintingStrategy(PaintingStrategy.POINTS);
squeezeline.AssignValueColor(if ExtrSqueeze then Color.yellow else if originalSqueeze then Color.RED else if presqueeze then Color.GRAY else Color.GREEN);

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);
 
@SleepyZ ... thanx so much for following up with the code updates (and sorry for my late response ... was on vacation this past week). I'll need to clean up some of the code as it takes forever to complete the chart. I suspect some of the original code needs some streamlining. Again, thanx for your time to work on this!! Much appreciated!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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