Clouds with TTM Squeeze Indicator for ThinkorSwim

Welkin

Welkin

Active member
VIP
I saw a video with John F. Carter explaining that the squeeze is when the Bollinger Bands cross inside of Keltner Channels. I decided to script it into cloud form. It appears this would have great applications for finding ranges to scalp as well.

thinkScript Code

Code:
#MTF Squeeze Clouds
#[email protected]

declare weak_volume_dependency;
input EnableAggregation2 = yes;
input EnableAggregation3 = yes;
input Aggregation1 = AggregationPeriod.FIVE_MIN;
input Aggregation2 = AggregationPeriod.THIRTY_MIN;
input Aggregation3 = AggregationPeriod.HOUR;
input displace = 0;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.SIMPLE;
input factor = 1.5;
input trueRangeAverageType = AverageType.SIMPLE;

def NA = Double.NaN;
def price1 = close("Period" = Aggregation1);
def price2 = close("Period" = Aggregation2);
def price3 = close("Period" = Aggregation3);

#BollingerBands
def sDev1 = StDev(data = price1[-displace], length = length);
def sDev2 = StDev(data = price2[-displace], length = length);
def sDev3 = StDev(data = price3[-displace], length = length);

def MidLine1 = MovingAverage(averageType, data = price1[-displace], length = length);
def MidLine2 = MovingAverage(averageType, data = price2[-displace], length = length);
def MidLine3 = MovingAverage(averageType, data = price3[-displace], length = length);

def BLowerBand1 = MidLine1 + Num_Dev_Dn * sDev1;
def BLowerBand2 = MidLine2 + Num_Dev_Dn * sDev2;
def BLowerBand3 = MidLine3 + Num_Dev_Dn * sDev3;

def BUpperBand1 = MidLine1 + Num_Dev_up * sDev1;
def BUpperBand2 = MidLine2 + Num_Dev_up * sDev2;
def BUpperBand3 = MidLine3 + Num_Dev_up * sDev3;

#Keltner Channels
def shift1 = factor * MovingAverage(trueRangeAverageType, TrueRange(high("Period" = Aggregation1), close("Period" = Aggregation1), low("Period" = Aggregation1)), length);
def shift2 = factor * MovingAverage(trueRangeAverageType, TrueRange(high("Period" = Aggregation2), close("Period" = Aggregation2), low("Period" = Aggregation2)), length);
def shift3 = factor * MovingAverage(trueRangeAverageType, TrueRange(high("Period" = Aggregation3), close("Period" = Aggregation3), low("Period" = Aggregation3)), length);

def average1 = MovingAverage(averageType, price1, length);
def average2 = MovingAverage(averageType, price2, length);
def average3 = MovingAverage(averageType, price3, length);

def Avg1 = average1[-displace];
def Avg2 = average2[-displace];
def Avg3 = average3[-displace];

def KUpperBand1 = average1[-displace] + shift1[-displace];
def kUpperBand2 = average2[-displace] + shift2[-displace];
def kUpperBand3 = average3[-displace] + shift3[-displace];

def KLowerBand1 = average1[-displace] - shift1[-displace];
def KLowerBand2 = average2[-displace] - shift2[-displace];
def KLowerBand3 = average3[-displace] - shift3[-displace];


#Squeeze upper and lower crossovers
def BollKeltUB1DiffH = if KUpperBand1 - BUpperBand1 <= 0 then NA else KUpperBand1;
def BollKeltUB1DiffL = if KUpperBand1 - BUpperBand1 <= 0 then NA else BUpperBand1;
def BollKeltLB1DiffH = if BLowerBand1 - KLowerBand1 <= 0 then NA else BLowerBand1;
def BollKeltLB1DiffL = if BLowerBand1 - KLowerBand1 <= 0 then NA else KLowerBand1;

def BollKeltUB2DiffH = if !EnableAggregation2 then NA else if KUpperBand2 - BUpperBand2 <= 0 then NA else KUpperBand2;
def BollKeltUB2DiffL = if !EnableAggregation2 then NA else if KUpperBand2 - BUpperBand2 <= 0 then NA else BUpperBand2;
def BollKeltLB2DiffH = if !EnableAggregation2 then NA else if BLowerBand2 - KLowerBand2 <= 0 then NA else BLowerBand2;
def BollKeltLB2DiffL = if !EnableAggregation2 then NA else if BLowerBand2 - KLowerBand2 <= 0 then NA else KLowerBand2;

def BollKeltUB3DiffH = if !EnableAggregation3 then NA else if KUpperBand3 - BUpperBand3 <= 0 then NA else KUpperBand3;
def BollKeltUB3DiffL = if !EnableAggregation3 then NA else if KUpperBand3 - BUpperBand3 <= 0 then NA else BUpperBand3;
def BollKeltLB3DiffH = if !EnableAggregation3 then NA else if BLowerBand3 - KLowerBand3 <= 0 then NA else BLowerBand3;
def BollKeltLB3DiffL = if !EnableAggregation3 then NA else if BLowerBand3 - KLowerBand3 <= 0 then NA else KLowerBand3;

#Cloud shading
AddCloud(BollKeltUB1DiffH, BollKeltUB1DiffL, Color.YELLOW, Color.YELLOW);
AddCloud(BollKeltLB1DiffH, BollKeltLB1DiffL, Color.YELLOW, Color.YELLOW);

AddCloud(BollKeltUB2DiffH, BollKeltUB2DiffL, Color.DARK_ORANGE, Color.DARK_ORANGE);
AddCloud(BollKeltLB2DiffH, BollKeltLB2DiffL, Color.DARK_ORANGE, Color.DARK_ORANGE);

AddCloud(BollKeltUB3DiffH, BollKeltUB3DiffL, Color.RED, Color.RED);
AddCloud(BollKeltLB3DiffH, BollKeltLB3DiffL, Color.RED, Color.RED);

Shareable Link: https://tos.mx/SZGo6Qe

clouds with ttm_squeeze to show correspondence


 
Last edited:
W

wen

New member
hello. the cloud barely see it, how can I make it bigger? thanks!
 
Welkin

Welkin

Active member
VIP
hello. the cloud barely see it, how can I make it bigger? thanks!
I think if the cloud is too small it is probably not a very significant squeeze. and I wouldn't want them to be too visually intrusive, personally.

But here you go, I made it so that you can artificially inflate the squeeze cloud's top and bottom values, the inside values will stay the same.

just toggle inflatesqueezeclouds to yes and change the inflatevalue
1.0 = 100% increase




https://tos.mx/uC4rgih

 
Last edited:
W

wen

New member
I think if the cloud is too small it is probably not a very significant squeeze. and I wouldn't want them to be too visually intrusive, personally.

But here you go, I made it so that you can artificially inflate the squeeze cloud's top and bottom values, the inside values will stay the same.

just toggle inflatesqueezeclouds to yes and change the inflatevalue
1.0 = 100% increase



Code:
#Bollinger and Keltner SQUEEZE 1.1
#[email protected]
#added a toggle for inflating the outer values to increase size if you want them more visible. the inside values remain the same.
def NA = Double.NaN;
input inflatesqueezeclouds = no;
input inflatevalue = 1.0;

#Bollinger and Keltner Bands
plot BollUpBand1 = BollingerBands()."UpperBand";
plot BollLowBand1 = BollingerBands()."LowerBand";
plot BollMidBand1 = BollingerBands()."MidLine";


BollUpBand1.Hide();
BollLowBand1.Hide();
BollMidBand1.Hide();

def KeltUpBand1 = KeltnerChannels()."Upper_Band";
def KeltLowBand1 = KeltnerChannels()."Lower_Band";


#squeeze upper and lower crossovers
def BollKeltUB1DiffH = if inflatesqueezeclouds and KeltUpBand1 - BollUpBand1 > 0 then  (KeltUpBand1 + ((KeltUpBand1 - BollUpBand1)* inflatevalue)) else if KeltUpBand1 - BollUpBand1 <= 0 then NA else KeltUpBand1;
def BollKeltUB1DiffL = if KeltUpBand1 - BollUpBand1 <= 0 then NA else BollUpBand1;
def BollKeltLB1DiffH = if BollLowBand1 - KeltLowBand1 <= 0 then NA else BollLowBand1;
def BollKeltLB1DiffL = if inflatesqueezeclouds and BollLowBand1 - KeltLowBand1 > 0 then (KeltLowBand1 -  ((BollLowBand1 - KeltLowBand1)*inflatevalue)) else if BollLowBand1 - KeltLowBand1 <= 0 then NA else KeltLowBand1;

#format
BollUpBand1.SetStyle(Curve.FIRM);
BollUpBand1.SetDefaultColor(CreateColor(204, 0, 204));
BollLowBand1.SetStyle(Curve.FIRM);
BollLowBand1.SetDefaultColor(CreateColor(0, 100, 200));
BollMidBand1.SetStyle(Curve.FIRM);
BollMidBand1.SetDefaultColor(CreateColor(150, 150, 255));

#Cloud shading
AddCloud(BollKeltUB1DiffH, BollKeltUB1DiffL, Color.YELLOW, Color.YELLOW);
AddCloud(BollKeltLB1DiffH, BollKeltLB1DiffL, Color.YELLOW, Color.YELLOW);

https://tos.mx/uC4rgih

oh. so if big squeeze the cloud will bigger(this is nice). if I change that will still have this function?
 
Welkin

Welkin

Active member
VIP
oh. so if big squeeze the cloud will bigger(this is nice). if I change that will still have this function?
its not an absolute, but from what I've seen after looking at them across a lot of charts, when they are thick with a more compact trading range the moves tend to have more substance. Again this isn't 100% or anything just observation, it could also have a small break in the squeeze clouds and continue sideways and form more squeeze clouds producing a type of channel, usually sloping towards one direction or another. Just keep in mind the overall context of what you're observing.
 
W

wen

New member
ok. BTW I did watched his YouTube channel just three ago. then I find u. lol.....THANK YOU!
 
M

mturtrader

New member
@Welkin Thanks for sharing. is it possible for this script to look up at different time frames for a squeeze and somehow show it on the chart? 5min/15min/30min/hourly/daily etc? also would it be possible to add long/short signals as well when in squeeze? TIA
 
D

dolomick

Member
This is cool, thanks! Could you possibly do clouds for when the bollinger band is outside the keltner channels (this would be a different indicator, I realize). Currently I have both on and it really helps identify strong moves when prices are between the bollinger and keltner edges, ie, they are outside keltner channel but inside the edge of the bollinger bands. Currently it is kind of messy having both on in my chart. Thanks!
 
Welkin

Welkin

Active member
VIP
This is cool, thanks! Could you possibly do clouds for when the bollinger band is outside the keltner channels (this would be a different indicator, I realize). Currently I have both on and it really helps identify strong moves when prices are between the bollinger and keltner edges, ie, they are outside keltner channel but inside the edge of the bollinger bands. Currently it is kind of messy having both on in my chart. Thanks!

not a hard change, this should do it: https://tos.mx/CFFtOoe
toggle OutlineClouds to no if you just want only clouds

 
D

dolomick

Member
Thanks for making my modification! I'm guessing this is still showing squeezes on the higher timeframes as the clouds sometimes appear for them but not always? How should I interpret those?

Also, is there a way to make this work on tick charts, even if it means making an alternate version that doesn't have multi-timeframe? Thanks!
 
Last edited:
Welkin

Welkin

Active member
VIP
Thanks for making my modification! I'm guessing this is still showing squeezes on the higher timeframes as the clouds sometimes appear for them but not always? How should I interpret those?

Also, is there a way to make this work on tick charts, even if it means making an alternate version that doesn't have multi-timeframe? Thanks!
Sorry for the late response. Yes it is still showing the squeezes from the higher time aggregations but you can disable them. simply toggle 'enable aggregation2' or 'enable aggregation3' to no.


the squeeze lets you see points of what is considered low volatility, a prelude to higher volatility. Often you will see them act as support or resistance until price breaks out. When you see them stack up it is an even greater indication of some potential higher volatile moves on larger time frames. Do some backtesting on multiple tickers and use your own analysis and determine if these are informative enough to be used in your personal trading strategies.

I recommend checking out two books that talk about the squeeze:
John Bollinger - Bollinger on Bollinger Bands chapter 8 and chapter 12
and John F Carter - Mastering the Trade (3rd edition) chapter 12 (or chapter 11 in the 2nd edition)

as far as having these on tick charts or even range charts, thats something i'll have to look into.

edit: I'd also like to note that I do not personally use the squeeze the same way John F Carter does, his focus is on higher time frames such as days/weeks/months and he doesn't have clouds on his chart AFAIK, only a momentum indicator with a dotted line that toggles from green to red when a squeeze is taking place. Being able to see what is actually happening with the squeeze is a huge benefit imo. My use of them is primarily on a 5min chart in conjunction with VWAP deviation bands using them as an areas of interest for reversals . Thats why i bundled it with this: https://usethinkscript.com/threads/ultimate-vwap-indicator-for-thinkorswim.1681/
 
Last edited:
D

dolomick

Member
Thanks! I actually have tried Simpler Trading's free trials for their chat rooms. I am trying to get a hold of his book at my local library but they are hard to get so I may have to buy it (Carter). My hunch is the multi-timeframe aspect is what is messing up the ability to use it on tick charts, that usually seems to be the case. If that part could be stripped out it would be useful for futures trading on tick charts - paired with price action and support/resistance, when price spikes out of the keltner and bollinger bands, it can be a good reliable scalp for a reversion to the mean. Conversely it can also show a strong momentum move to trade with the trend.
 
Welkin

Welkin

Active member
VIP
Thanks! I actually have tried Simpler Trading's free trials for their chat rooms. I am trying to get a hold of his book at my local library but they are hard to get so I may have to buy it (Carter). My hunch is the multi-timeframe aspect is what is messing up the ability to use it on tick charts, that usually seems to be the case. If that part could be stripped out it would be useful for futures trading on tick charts - paired with price action and support/resistance, when price spikes out of the keltner and bollinger bands, it can be a good reliable scalp for a reversion to the mean. Conversely it can also show a strong momentum move to trade with the trend.
here you go try this one, it doesn't have MTF squeeze clouds https://tos.mx/uC4rgih

I haven't looked explored its use on tick charts, thats definitely something to look into. I have a small pane with a 5tick range chart that i like to use, easier to see patterns forming on it, and have better idea of what price action is saying. I also use a reversion to mean strategy, but I use VWAP deviations not bollinger bands.
drop me an email perhaps i have some resources i'd like to share that you'd probably be interested in (or anyone else if they want :)). welkincall at gmail.
 
D

DeusMecanicus

Member
@Welkin I decided to modify the cloud color to reflect the original TTM_Squeeze momentum color. Then i saw that you released a MTF version so I did that one too.





Code:
#Bollinger and Keltner SQUEEZE 1.1
#[email protected]
#added a toggle for inflating the outer values to increase size if you want them more visible. the inside values remain the same.
#Addcloud Mod - DeusMecanicus

def NA = Double.NaN;
input inflatesqueezeclouds = no;
input inflatevalue = 1.0;
input addcloud = yes;

#Momentum Squeeze - Mobius
input length = 20; #hint length: Length for average calculation
input price = close;
def K = (Highest(high, length) + Lowest(low, length)) /
               2 + ExpAverage(close, length);
def Momo = Inertia(price - K / 2, length);
# End Momentum Squeeze - Mobius

#Bollinger and Keltner Bands
plot BollUpBand1 = BollingerBands()."UpperBand";
plot BollLowBand1 = BollingerBands()."LowerBand";
plot BollMidBand1 = BollingerBands()."MidLine";


BollUpBand1.Hide();
BollLowBand1.Hide();
BollMidBand1.Hide();

def KeltUpBand1 = KeltnerChannels()."Upper_Band";
def KeltLowBand1 = KeltnerChannels()."Lower_Band";


#squeeze upper and lower crossovers
plot BollKeltUB1DiffH = if inflatesqueezeclouds and KeltUpBand1 - BollUpBand1 > 0 then  (KeltUpBand1 + ((KeltUpBand1 - BollUpBand1) * inflatevalue)) else if KeltUpBand1 - BollUpBand1 <= 0 then NA else KeltUpBand1;
BollKeltUB1DiffH.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);

plot BollKeltUB1DiffL = if KeltUpBand1 - BollUpBand1 <= 0 then NA else BollUpBand1;
BollKeltUB1DiffL.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);

plot BollKeltLB1DiffH = if BollLowBand1 - KeltLowBand1 <= 0 then NA else BollLowBand1;
BollKeltLB1DiffH.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);

plot BollKeltLB1DiffL = if inflatesqueezeclouds and BollLowBand1 - KeltLowBand1 > 0 then (KeltLowBand1 -  ((BollLowBand1 - KeltLowBand1) * inflatevalue)) else if BollLowBand1 - KeltLowBand1 <= 0 then NA else KeltLowBand1;
BollKeltLB1DiffL.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);

#format
BollUpBand1.SetStyle(Curve.FIRM);
BollUpBand1.SetDefaultColor(CreateColor(204, 0, 204));
BollLowBand1.SetStyle(Curve.FIRM);
BollLowBand1.SetDefaultColor(CreateColor(0, 100, 200));
BollMidBand1.SetStyle(Curve.FIRM);
BollMidBand1.SetDefaultColor(CreateColor(150, 150, 255));

#Cloud shading

#Cyan cloud
def notcyan = Momo < Momo[1] and Momo > 0 or Momo < 0 and Momo < Momo[1] or Momo < 0 and momo > momo[1];
def CyanCloud1 = if  notcyan  then Double.NaN else if addcloud then BollKeltUB1DiffL else Double.NaN;
def CyanCloud2 = if notcyan then Double.NaN else if addcloud then BollKeltUB1DiffH  else Double.NaN;
AddCloud(Cyancloud2, CyanCloud1, Color.cyan);
def CyanCloud3 = if notcyan then Double.NaN else if addcloud then BollKeltLB1DiffL  else Double.NaN;
def CyanCloud4 = if notcyan then Double.NaN else if addcloud then BollKeltLB1DiffH  else Double.NaN;
AddCloud(CyanCloud4, CyanCloud3, Color.cyan);

#Blue Cloud
def notblue = Momo > Momo[1] and Momo > 0 or Momo < 0 and Momo < Momo[1] or Momo < 0 and momo > momo[1];
def BlueCloud1 = if  notblue  then Double.NaN else if addcloud then BollKeltUB1DiffL else Double.NaN;
def BlueCloud2 = if notblue then Double.NaN else if addcloud then BollKeltUB1DiffH  else Double.NaN;
AddCloud(Bluecloud2, BlueCloud1, Color.blue);
def BlueCloud3 = if notblue then Double.NaN else if addcloud then BollKeltLB1DiffL  else Double.NaN;
def BlueCloud4 = if notblue then Double.NaN else if addcloud then BollKeltLB1DiffH  else Double.NaN;
AddCloud(BlueCloud4, BlueCloud3, Color.blue);

#Red Cloud
def notred = Momo > Momo[1] and Momo > 0 or Momo > 0 and Momo < Momo[1] or Momo < 0 and momo > momo[1];
def RedCloud1 = if  notred  then Double.NaN else if addcloud then BollKeltUB1DiffL else Double.NaN;
def RedCloud2 = if notred then Double.NaN else if addcloud then BollKeltUB1DiffH  else Double.NaN;
AddCloud(RedCloud2, RedCloud1, Color.red);
def RedCloud3 = if notred then Double.NaN else if addcloud then BollKeltLB1DiffL  else Double.NaN;
def RedCloud4 = if notred then Double.NaN else if addcloud then BollKeltLB1DiffH  else Double.NaN;
AddCloud(RedCloud4, RedCloud3, Color.red);

#Yellow Cloud
def notyellow = Momo > Momo[1] and Momo > 0 or Momo > 0 and Momo < Momo[1] or Momo < 0 and momo < momo[1];
def YellowCloud1 = if  notyellow  then Double.NaN else if addcloud then BollKeltUB1DiffL else Double.NaN;
def YellowCloud2 = if notyellow then Double.NaN else if addcloud then BollKeltUB1DiffH  else Double.NaN;
AddCloud(YellowCloud2, YellowCloud1, Color.yellow);
def YellowCloud3 = if notyellow then Double.NaN else if addcloud then BollKeltLB1DiffL  else Double.NaN;
def YellowCloud4 = if notyellow then Double.NaN else if addcloud then BollKeltLB1DiffH  else Double.NaN;
AddCloud(YellowCloud4, YellowCloud3, Color.yellow);

#AddCloud(BollKeltUB1DiffH, BollKeltUB1DiffL, Color.YELLOW, Color.YELLOW);
#AddCloud(BollKeltLB1DiffH, BollKeltLB1DiffL, Color.YELLOW, Color.YELLOW);

Code:
#MTF Squeeze Clouds
#[email protected]
#Addcloud mod - DeusMecanicus

declare weak_volume_dependency;
input EnableAggregation2 = yes;
input EnableAggregation3 = yes;
input Aggregation1 = AggregationPeriod.FIVE_MIN;
input Aggregation2 = AggregationPeriod.THIRTY_MIN;
input Aggregation3 = AggregationPeriod.HOUR;
input displace = 0;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.SIMPLE;
input factor = 1.5;
input trueRangeAverageType = AverageType.SIMPLE;
input addcloud = yes;
input addcloud2 = yes;
input addcloud3 = yes;
def NA = Double.NaN;
def price1 = close("Period" = Aggregation1);
def price2 = close("Period" = Aggregation2);
def price3 = close("Period" = Aggregation3);

#Borrowed from Momentum Squeeze - Mobius
#input length = 20; #hint length: Length for average calculation
def K = (Highest(high("Period" = Aggregation1), length) + Lowest(low("Period" = Aggregation1), length)) /
               2 + ExpAverage(close("Period" = Aggregation1), length);
def Momo = Inertia(price1 - K / 2, length);
input length2 = 20; #hint length: Length for average calculation
def K2 = (Highest(high("Period" = Aggregation2), length2) + Lowest(low("Period" = Aggregation2), length2)) /
               2 + ExpAverage(close("Period" = Aggregation2), length2);
def Momo2 = Inertia(price2 - K2 / 2, length2);
input length3 = 20; #hint length: Length for average calculation
def K3 = (Highest(high("Period" = Aggregation3), length3) + Lowest(low("Period" = Aggregation3), length3)) /
               2 + ExpAverage(close("Period" = Aggregation3), length3);
def Momo3 = Inertia(price3 - K3 / 2, length3);
# End Momo


#BollingerBands
def sDev1 = StDev(data = price1[-displace], length = length);
def sDev2 = StDev(data = price2[-displace], length = length);
def sDev3 = StDev(data = price3[-displace], length = length);

def MidLine1 = MovingAverage(averageType, data = price1[-displace], length = length);
def MidLine2 = MovingAverage(averageType, data = price2[-displace], length = length);
def MidLine3 = MovingAverage(averageType, data = price3[-displace], length = length);

def BLowerBand1 = MidLine1 + Num_Dev_Dn * sDev1;
def BLowerBand2 = MidLine2 + Num_Dev_Dn * sDev2;
def BLowerBand3 = MidLine3 + Num_Dev_Dn * sDev3;

def BUpperBand1 = MidLine1 + Num_Dev_up * sDev1;
def BUpperBand2 = MidLine2 + Num_Dev_up * sDev2;
def BUpperBand3 = MidLine3 + Num_Dev_up * sDev3;

#Keltner Channels
def shift1 = factor * MovingAverage(trueRangeAverageType, TrueRange(high("Period" = Aggregation1), close("Period" = Aggregation1), low("Period" = Aggregation1)), length);
def shift2 = factor * MovingAverage(trueRangeAverageType, TrueRange(high("Period" = Aggregation2), close("Period" = Aggregation2), low("Period" = Aggregation2)), length);
def shift3 = factor * MovingAverage(trueRangeAverageType, TrueRange(high("Period" = Aggregation3), close("Period" = Aggregation3), low("Period" = Aggregation3)), length);

def average1 = MovingAverage(averageType, price1, length);
def average2 = MovingAverage(averageType, price2, length);
def average3 = MovingAverage(averageType, price3, length);

def Avg1 = average1[-displace];
def Avg2 = average2[-displace];
def Avg3 = average3[-displace];

def KUpperBand1 = average1[-displace] + shift1[-displace];
def kUpperBand2 = average2[-displace] + shift2[-displace];
def kUpperBand3 = average3[-displace] + shift3[-displace];

def KLowerBand1 = average1[-displace] - shift1[-displace];
def KLowerBand2 = average2[-displace] - shift2[-displace];
def KLowerBand3 = average3[-displace] - shift3[-displace];


#Squeeze upper and lower crossovers
#1
plot BollKeltUB1DiffH = if KUpperBand1 - BUpperBand1 <= 0 then NA else KUpperBand1;
BollKeltUB1DiffH.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);
plot BollKeltUB1DiffL = if KUpperBand1 - BUpperBand1 <= 0 then NA else BUpperBand1;
BollKeltUB1DiffL.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);
plot BollKeltLB1DiffH = if BLowerBand1 - KLowerBand1 <= 0 then NA else BLowerBand1;
BollKeltLB1DiffH.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);
plot BollKeltLB1DiffL = if BLowerBand1 - KLowerBand1 <= 0 then NA else KLowerBand1;
BollKeltLB1DiffL.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);

#2
plot BollKeltUB2DiffH = if !EnableAggregation2 then NA else if KUpperBand2 - BUpperBand2 <= 0 then NA else KUpperBand2;
BollKeltUB2DiffH.assignvaluecolor(if Momo2 > Momo2[1] and Momo2 > 0 then Color.CYAN else if Momo2 > 0 and Momo2 < Momo2[1] then Color.BLUE else if Momo2 < 0 and Momo2 < Momo2[1] then Color.RED else if Momo2 < 0 and Momo2 > Momo2[1] then Color.YELLOW else Color.GRAY);
plot BollKeltUB2DiffL = if !EnableAggregation2 then NA else if KUpperBand2 - BUpperBand2 <= 0 then NA else BUpperBand2;
BollKeltUB2DiffL.assignvaluecolor(if Momo2 > Momo2[1] and Momo2 > 0 then Color.CYAN else if Momo2 > 0 and Momo2 < Momo2[1] then Color.BLUE else if Momo2 < 0 and Momo2 < Momo2[1] then Color.RED else if Momo2 < 0 and Momo2 > Momo2[1] then Color.YELLOW else Color.GRAY);
plot BollKeltLB2DiffH = if !EnableAggregation2 then NA else if BLowerBand2 - KLowerBand2 <= 0 then NA else BLowerBand2;
BollKeltLB2DiffH.assignvaluecolor(if Momo2 > Momo2[1] and Momo2 > 0 then Color.CYAN else if Momo2 > 0 and Momo2 < Momo2[1] then Color.BLUE else if Momo2 < 0 and Momo2 < Momo2[1] then Color.RED else if Momo2 < 0 and Momo2 > Momo2[1] then Color.YELLOW else Color.GRAY);
plot BollKeltLB2DiffL = if !EnableAggregation2 then NA else if BLowerBand2 - KLowerBand2 <= 0 then NA else KLowerBand2;
BollKeltLB2DiffL.assignvaluecolor(if Momo2 > Momo2[1] and Momo2 > 0 then Color.CYAN else if Momo2 > 0 and Momo2 < Momo2[1] then Color.BLUE else if Momo2 < 0 and Momo2 < Momo2[1] then Color.RED else if Momo2 < 0 and Momo2 > Momo2[1] then Color.YELLOW else Color.GRAY);
#3
plot BollKeltUB3DiffH = if !EnableAggregation3 then NA else if KUpperBand3 - BUpperBand3 <= 0 then NA else KUpperBand3;
BollKeltUB3DiffH.assignvaluecolor(if Momo3 > Momo3[1] and Momo3 > 0 then Color.CYAN else if Momo3 > 0 and Momo3 < Momo3[1] then Color.BLUE else if Momo3 < 0 and Momo3 < Momo3[1] then Color.RED else if Momo3 < 0 and Momo3 > Momo3[1] then Color.YELLOW else Color.WHITE);
plot BollKeltUB3DiffL = if !EnableAggregation3 then NA else if KUpperBand3 - BUpperBand3 <= 0 then NA else BUpperBand3;
BollKeltUB3DiffL.assignvaluecolor(if Momo3 > Momo3[1] and Momo3 > 0 then Color.CYAN else if Momo3 > 0 and Momo3 < Momo3[1] then Color.BLUE else if Momo3 < 0 and Momo3 < Momo3[1] then Color.RED else if Momo3 < 0 and Momo3 > Momo3[1] then Color.YELLOW else Color.WHITE);
plot BollKeltLB3DiffH = if !EnableAggregation3 then NA else if BLowerBand3 - KLowerBand3 <= 0 then NA else BLowerBand3;
BollKeltLB3DiffH.assignvaluecolor(if Momo3 > Momo3[1] and Momo3 > 0 then Color.CYAN else if Momo3 > 0 and Momo3 < Momo3[1] then Color.BLUE else if Momo3 < 0 and Momo3 < Momo3[1] then Color.RED else if Momo3 < 0 and Momo3 > Momo3[1] then Color.YELLOW else Color.WHITE);
plot BollKeltLB3DiffL = if !EnableAggregation3 then NA else if BLowerBand3 - KLowerBand3 <= 0 then NA else KLowerBand3;
BollKeltLB3DiffL.assignvaluecolor(if Momo3 > Momo3[1] and Momo3 > 0 then Color.CYAN else if Momo3 > 0 and Momo3 < Momo3[1] then Color.BLUE else if Momo3 < 0 and Momo3 < Momo3[1] then Color.RED else if Momo3 < 0 and Momo3 > Momo3[1] then Color.YELLOW else Color.WHITE);


#Cloud shading1
#Cyan cloud
def notcyan = Momo < Momo[1] and Momo > 0 or Momo < 0 and Momo < Momo[1] or Momo < 0 and momo > momo[1];
def CyanCloud1 = if  notcyan  then Double.NaN else if addcloud then BollKeltUB1DiffL else Double.NaN;
def CyanCloud2 = if notcyan then Double.NaN else if addcloud then BollKeltUB1DiffH  else Double.NaN;
AddCloud(Cyancloud2, CyanCloud1, Color.cyan);
def CyanCloud3 = if notcyan then Double.NaN else if addcloud then BollKeltLB1DiffL  else Double.NaN;
def CyanCloud4 = if notcyan then Double.NaN else if addcloud then BollKeltLB1DiffH  else Double.NaN;
AddCloud(CyanCloud4, CyanCloud3, Color.cyan);

#Blue Cloud
def notblue = Momo > Momo[1] and Momo > 0 or Momo < 0 and Momo < Momo[1] or Momo < 0 and momo > momo[1];
def BlueCloud1 = if  notblue  then Double.NaN else if addcloud then BollKeltUB1DiffL else Double.NaN;
def BlueCloud2 = if notblue then Double.NaN else if addcloud then BollKeltUB1DiffH  else Double.NaN;
AddCloud(Bluecloud2, BlueCloud1, Color.blue);
def BlueCloud3 = if notblue then Double.NaN else if addcloud then BollKeltLB1DiffL  else Double.NaN;
def BlueCloud4 = if notblue then Double.NaN else if addcloud then BollKeltLB1DiffH  else Double.NaN;
AddCloud(BlueCloud4, BlueCloud3, Color.blue);

#Red Cloud
def notred = Momo > Momo[1] and Momo > 0 or Momo > 0 and Momo < Momo[1] or Momo < 0 and momo > momo[1];
def RedCloud1 = if  notred  then Double.NaN else if addcloud then BollKeltUB1DiffL else Double.NaN;
def RedCloud2 = if notred then Double.NaN else if addcloud then BollKeltUB1DiffH  else Double.NaN;
AddCloud(RedCloud2, RedCloud1, Color.red);
def RedCloud3 = if notred then Double.NaN else if addcloud then BollKeltLB1DiffL  else Double.NaN;
def RedCloud4 = if notred then Double.NaN else if addcloud then BollKeltLB1DiffH  else Double.NaN;
AddCloud(RedCloud4, RedCloud3, Color.red);

#Yellow Cloud
def notyellow = Momo > Momo[1] and Momo > 0 or Momo > 0 and Momo < Momo[1] or Momo < 0 and momo < momo[1];
def YellowCloud1 = if  notyellow  then Double.NaN else if addcloud then BollKeltUB1DiffL else Double.NaN;
def YellowCloud2 = if notyellow then Double.NaN else if addcloud then BollKeltUB1DiffH  else Double.NaN;
AddCloud(YellowCloud2, YellowCloud1, Color.yellow);
def YellowCloud3 = if notyellow then Double.NaN else if addcloud then BollKeltLB1DiffL  else Double.NaN;
def YellowCloud4 = if notyellow then Double.NaN else if addcloud then BollKeltLB1DiffH  else Double.NaN;
AddCloud(YellowCloud4, YellowCloud3, Color.yellow);
#AddCloud(BollKeltUB1DiffH, BollKeltUB1DiffL, Color.YELLOW, Color.YELLOW);
#AddCloud(BollKeltLB1DiffH, BollKeltLB1DiffL, Color.YELLOW, Color.YELLOW);

#Cloud shading2
#Cyan cloud
def notcyan2 = Momo2 < Momo2[1] and Momo2 > 0 or Momo2 < 0 and Momo2 < Momo2[1] or Momo2 < 0 and momo2 > momo2[1];
def CyanCloud12 = if  notcyan2  then Double.NaN else if addcloud2 then BollKeltUB2DiffL else Double.NaN;
def CyanCloud22 = if notcyan2 then Double.NaN else if addcloud2 then BollKeltUB2DiffH  else Double.NaN;
AddCloud(Cyancloud22, CyanCloud12, Color.cyan);
def CyanCloud32 = if notcyan2 then Double.NaN else if addcloud2 then BollKeltLB2DiffL  else Double.NaN;
def CyanCloud42 = if notcyan2 then Double.NaN else if addcloud2 then BollKeltLB2DiffH  else Double.NaN;
AddCloud(CyanCloud42, CyanCloud32, Color.cyan);

#Blue Cloud
def notblue2 = Momo2 > Momo2[1] and Momo2 > 0 or Momo2 < 0 and Momo2 < Momo2[1] or Momo2 < 0 and momo2 > momo2[1];
def BlueCloud12 = if  notblue2  then Double.NaN else if addcloud2 then BollKeltUB2DiffL else Double.NaN;
def BlueCloud22 = if notblue2 then Double.NaN else if addcloud2 then BollKeltUB2DiffH  else Double.NaN;
AddCloud(Bluecloud22, BlueCloud12, Color.blue);
def BlueCloud32 = if notblue2 then Double.NaN else if addcloud2 then BollKeltLB2DiffL  else Double.NaN;
def BlueCloud42 = if notblue2 then Double.NaN else if addcloud2 then BollKeltLB2DiffH  else Double.NaN;
AddCloud(BlueCloud42, BlueCloud32, Color.blue);

#Red Cloud
def notred2 = Momo2 > Momo2[1] and Momo2 > 0 or Momo2 > 0 and Momo2 < Momo2[1] or Momo2 < 0 and momo2 > momo2[1];
def RedCloud12 = if  notred2  then Double.NaN else if addcloud2 then BollKeltUB2DiffL else Double.NaN;
def RedCloud22 = if notred2 then Double.NaN else if addcloud2 then BollKeltUB2DiffH  else Double.NaN;
AddCloud(RedCloud22, RedCloud12, Color.red);
def RedCloud32 = if notred2 then Double.NaN else if addcloud2 then BollKeltLB2DiffL  else Double.NaN;
def RedCloud42 = if notred2 then Double.NaN else if addcloud2 then BollKeltLB2DiffH  else Double.NaN;
AddCloud(RedCloud42, RedCloud32, Color.red);

#Yellow Cloud
def notyellow2 = Momo2 > Momo2[1] and Momo2 > 0 or Momo2 > 0 and Momo2 < Momo2[1] or Momo2 < 0 and momo2 < momo2[1];
def YellowCloud12 = if  notyellow2  then Double.NaN else if addcloud2 then BollKeltUB2DiffL else Double.NaN;
def YellowCloud22= if notyellow2 then Double.NaN else if addcloud2 then BollKeltUB2DiffH  else Double.NaN;
AddCloud(YellowCloud22, YellowCloud12, Color.yellow);
def YellowCloud32 = if notyellow2 then Double.NaN else if addcloud2 then BollKeltLB2DiffL  else Double.NaN;
def YellowCloud42 = if notyellow2 then Double.NaN else if addcloud2 then BollKeltLB2DiffH  else Double.NaN;
AddCloud(YellowCloud42, YellowCloud32, Color.yellow);
#AddCloud(BollKeltUB2DiffH, BollKeltUB2DiffL, Color.DARK_ORANGE, Color.DARK_ORANGE);
#AddCloud(BollKeltLB2DiffH, BollKeltLB2DiffL, Color.DARK_ORANGE, Color.DARK_ORANGE);

#Cloud shading3
#Cyan cloud
def notcyan3 = Momo3 < Momo3[1] and Momo3 > 0 or Momo3 < 0 and Momo3 < Momo3[1] or Momo3 < 0 and momo3 > momo3[1];
def CyanCloud13 = if  notcyan3  then Double.NaN else if addcloud3 then BollKeltUB3DiffL else Double.NaN;
def CyanCloud23 = if notcyan3 then Double.NaN else if addcloud3 then BollKeltUB3DiffH  else Double.NaN;
AddCloud(Cyancloud23, CyanCloud13, Color.cyan);
def CyanCloud33 = if notcyan3 then Double.NaN else if addcloud3 then BollKeltLB3DiffL  else Double.NaN;
def CyanCloud43 = if notcyan3 then Double.NaN else if addcloud3 then BollKeltLB3DiffH  else Double.NaN;
AddCloud(CyanCloud43, CyanCloud33, Color.cyan);

#Blue Cloud
def notblue3 = Momo3 > Momo3[1] and Momo3 > 0 or Momo3 < 0 and Momo3 < Momo3[1] or Momo3 < 0 and momo3 > momo3[1];
def BlueCloud13 = if  notblue3 then Double.NaN else if addcloud3 then BollKeltUB3DiffL else Double.NaN;
def BlueCloud23 = if notblue3 then Double.NaN else if addcloud3 then BollKeltUB3DiffH  else Double.NaN;
AddCloud(Bluecloud23, BlueCloud13, Color.blue);
def BlueCloud33 = if notblue3 then Double.NaN else if addcloud3 then BollKeltLB3DiffL  else Double.NaN;
def BlueCloud43 = if notblue3 then Double.NaN else if addcloud3 then BollKeltLB3DiffH  else Double.NaN;
AddCloud(BlueCloud43, BlueCloud33, Color.blue);

#Red Cloud
def notred3 = Momo3 > Momo3[1] and Momo3 > 0 or Momo3 > 0 and Momo3 < Momo3[1] or Momo3 < 0 and momo3 > momo3[1];
def RedCloud13 = if  notred3  then Double.NaN else if addcloud3 then BollKeltUB3DiffL else Double.NaN;
def RedCloud23 = if notred3 then Double.NaN else if addcloud3 then BollKeltUB3DiffH  else Double.NaN;
AddCloud(RedCloud23, RedCloud13, Color.red);
def RedCloud33 = if notred3 then Double.NaN else if addcloud3 then BollKeltLB3DiffL  else Double.NaN;
def RedCloud43 = if notred3 then Double.NaN else if addcloud3 then BollKeltLB3DiffH  else Double.NaN;
AddCloud(RedCloud43, RedCloud33, Color.red);

#Yellow Cloud
def notyellow3 = Momo3 > Momo3[1] and Momo3 > 0 or Momo3 > 0 and Momo3 < Momo3[1] or Momo3 < 0 and momo3 < momo3[1];
def YellowCloud13 = if  notyellow3  then Double.NaN else if addcloud3 then BollKeltUB3DiffL else Double.NaN;
def YellowCloud23 = if notyellow3 then Double.NaN else if addcloud3 then BollKeltUB3DiffH  else Double.NaN;
AddCloud(YellowCloud23, YellowCloud13, Color.yellow);
def YellowCloud33 = if notyellow3 then Double.NaN else if addcloud3 then BollKeltLB3DiffL  else Double.NaN;
def YellowCloud43 = if notyellow3 then Double.NaN else if addcloud3 then BollKeltLB3DiffH  else Double.NaN;
AddCloud(YellowCloud43, YellowCloud33, Color.yellow);
#AddCloud(BollKeltUB3DiffH, BollKeltUB3DiffL, Color.RED, Color.RED);
#AddCloud(BollKeltLB3DiffH, BollKeltLB3DiffL, Color.RED, Color.RED);
 
Last edited by a moderator:
Welkin

Welkin

Active member
VIP
@DeusMecanicus looks interesting, thank you for the modifications(y)
 
T

Topas

New member
We all know John F. Carter and his Squeeze indicator, In this lock-down he came up with another idea to take Squeeze to much higher level and came up with Squeeze Pro
Just Wanted to bring to everyone's ( specially coder) attention. I feel this is wonderful coder community and trying to come up with some thing new some reliable way to trade. I don't think there is no wrong doing if we could get idea and build our own from the scratch as long as we don't copy and paste his original code

I think this is nice way for momentum trading ... knowing when the market will move big and what direction
I will encourage coder trader to have a look ... they may come with something similar... that will help the new trader trade confidently
thank you

 
Last edited by a moderator:
Thread starter Similar threads Forum Replies Date
RmS59 Turning Clouds on and off... Questions 11
P Adding clouds to OB and OS on Williams%R Questions 2
Daedalus77 Show or Hide Clouds Questions 2
C TTM Squeeze Fire Signal - Another Take! Indicators 9
H TTM trend scanner Questions 2

Similar threads

Top