standalone Squeeze for upper chart?

METAL

Well-known member
Plus
I am looking for a squeeze indicator that will place a dot or dots above or below candle when squeeze releases
 
Solution
I am looking for a squeeze indicator that will place a dot or dots above or below candle when squeeze releases


this is how i would do it,

find the squeeze study. ttm_squeeze
the whole code isn't availble, but the plots are, so you can figure out what it is doing.
plot Histogram = Double.NaN;
plot VolComp = Double.NaN;
plot SqueezeAlert = Double.NaN;

add a bubble to show a plot variable, to figure out what it does.

to read a value in another study, write a formula like this, study name and plot name,
you can add parameters in between the ( ) if you don't want the defaults.

def sqz = ttm_squeeze().SqueezeAlert;

i'm not sure what a released squeeze is, but i guess it is after a squeeze.
so we need to find a bar not in a...
I am looking for a squeeze indicator that will place a dot or dots above or below candle when squeeze releases


this is how i would do it,

find the squeeze study. ttm_squeeze
the whole code isn't availble, but the plots are, so you can figure out what it is doing.
plot Histogram = Double.NaN;
plot VolComp = Double.NaN;
plot SqueezeAlert = Double.NaN;

add a bubble to show a plot variable, to figure out what it does.

to read a value in another study, write a formula like this, study name and plot name,
you can add parameters in between the ( ) if you don't want the defaults.

def sqz = ttm_squeeze().SqueezeAlert;

i'm not sure what a released squeeze is, but i guess it is after a squeeze.
so we need to find a bar not in a squeeze and the previous bar was in a squeeze.

if we add a bubble, we can see what the sqz values are,

addchartbubble(1, 0, sqz, (if sqz==0 then color.yellow else color.gray), yes);

sqz is 0 when in a squeeze, when the dots are red.

then we can write a formula that is true on the bar after a squeeze.

def after = sqz[1] == 0 and sqz[0] == 1;

now we know what variable does what for the condition you want to ineract with.

i added dots. then i added arrows.
can turn either on/off


Code:
#ttm_squeeze_after

# https://usethinkscript.com/threads/is-there-a-standalone-squeeze-indicator-for-upper-chart.17280/
#Is there a standalone Squeeze indicator for upper chart?
#METAL  11/26
#I am looking for a squeeze indicator that will place a dot or dots above or below candle when squeeze releases

#---------------------------
# ttm_squeeze
#declare lower;
input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
#plot Histogram = Double.NaN;
#plot VolComp = Double.NaN;
#plot SqueezeAlert = Double.NaN;
#---------------------------

def na = double.nan;
def bn = barnumber();

def histo = ttm_squeeze().histogram;
def sqz = ttm_squeeze().SqueezeAlert; 

input test1 = no;
addchartbubble(test1, low, 
sqz + "\nsqz"
, (if sqz==0 then color.yellow else color.gray), no);
def after = sqz[1] == 0 and sqz == 1;


input arrows = yes;
plot zup = if (arrows and after and histo > histo[1]) then low*0.99 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_up);
zup.SetDefaultColor(Color.green);
zup.setlineweight(4);
zup.hidebubble();


plot zdwn = if (arrows and after and histo < histo[1]) then high*1.01 else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.red);
zdwn.setlineweight(4);
zdwn.hidebubble();


input dots = no;
plot za = if dots and after then high*1.02 else na;
za.SetPaintingStrategy(PaintingStrategy.POINTS);
#za.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
za.SetDefaultColor(Color.cyan);
za.setlineweight(5);
za.hidebubble();
#

top chart has arrows when a ttm squeeze ends
bottom chart is ttm squeeze
IgjcVSq.jpg
 
Solution
this is how i would do it,

find the squeeze study. ttm_squeeze
the whole code isn't availble, but the plots are, so you can figure out what it is doing.
plot Histogram = Double.NaN;
plot VolComp = Double.NaN;
plot SqueezeAlert = Double.NaN;

add a bubble to show a plot variable, to figure out what it does.

to read a value in another study, write a formula like this, study name and plot name,
you can add parameters in between the ( ) if you don't want the defaults.

def sqz = ttm_squeeze().SqueezeAlert;

i'm not sure what a released squeeze is, but i guess it is after a squeeze.
so we need to find a bar not in a squeeze and the previous bar was in a squeeze.

if we add a bubble, we can see what the sqz values are,

addchartbubble(1, 0, sqz, (if sqz==0 then color.yellow else color.gray), yes);

sqz is 0 when in a squeeze, when the dots are red.

then we can write a formula that is true on the bar after a squeeze.

def after = sqz[1] == 0 and sqz[0] == 1;

now we know what variable does what for the condition you want to ineract with.

i added dots. then i added arrows.
can turn either on/off


Code:
#ttm_squeeze_after

# https://usethinkscript.com/threads/is-there-a-standalone-squeeze-indicator-for-upper-chart.17280/
#Is there a standalone Squeeze indicator for upper chart?
#METAL  11/26
#I am looking for a squeeze indicator that will place a dot or dots above or below candle when squeeze releases

#---------------------------
# ttm_squeeze
#declare lower;
input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
#plot Histogram = Double.NaN;
#plot VolComp = Double.NaN;
#plot SqueezeAlert = Double.NaN;
#---------------------------

def na = double.nan;
def bn = barnumber();

def histo = ttm_squeeze().histogram;
def sqz = ttm_squeeze().SqueezeAlert;

input test1 = no;
addchartbubble(test1, low,
sqz + "\nsqz"
, (if sqz==0 then color.yellow else color.gray), no);
def after = sqz[1] == 0 and sqz == 1;


input arrows = yes;
plot zup = if (arrows and after and histo > histo[1]) then low*0.99 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_up);
zup.SetDefaultColor(Color.green);
zup.setlineweight(4);
zup.hidebubble();


plot zdwn = if (arrows and after and histo < histo[1]) then high*1.01 else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.red);
zdwn.setlineweight(4);
zdwn.hidebubble();


input dots = no;
plot za = if dots and after then high*1.02 else na;
za.SetPaintingStrategy(PaintingStrategy.POINTS);
#za.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
za.SetDefaultColor(Color.cyan);
za.setlineweight(5);
za.hidebubble();
#

top chart has arrows when a ttm squeeze ends
bottom chart is ttm squeeze
IgjcVSq.jpg
@halcyonguy Thank you a ton. Is there a chance I could get you to color the bars gray or yellow or something when a squeeze is happening?
 
Update. I got the bars to color gray during the squeeze but I cannot get the candles to color after the release either up or down. I think it will make for a cleaner chart to have the "Zup" to be a cyan bar and "Zdn" to be a magenta bar in place of candles or if it makes it easier to add the option to have arrows or not. Can someone help with this?

Code:
#ttm_squeeze_after

# https://usethinkscript.com/threads/is-there-a-standalone-squeeze-indicator-for-upper-chart.17280/
#Is there a standalone Squeeze indicator for upper chart?
#METAL 11/26
#I am looking for a squeeze indicator that will place a dot or dots above or below the candle when the squeeze releases

# Define conditions for arrows
def sqz = ttm_squeeze().SqueezeAlert;
def during_squeeze = sqz == 1;
def after = sqz[1] == 0 and sqz == 1;
def histo = ttm_squeeze().histogram;

# Set the default color
AssignPriceColor(if during_squeeze then Color.CURRENT else Color.GRAY);

# Arrows
input arrows = yes;

plot zup = if (arrows and after and histo > histo[1]) then low * 0.99 else Double.NaN;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.GREEN);
zup.SetLineWeight(4);

plot zdwn = if (arrows and after and histo < histo[1]) then high * 1.01 else Double.NaN;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.RED);
zdwn.SetLineWeight(4);

# Points
input dots = no;

plot za = if (dots and after) then high * 1.02 else Double.NaN;
za.SetPaintingStrategy(PaintingStrategy.POINTS);
za.SetDefaultColor(Color.CYAN);
za.SetLineWeight(5);
 
Update. I got the bars to color gray during the squeeze but I cannot get the candles to color after the release either up or down. I think it will make for a cleaner chart to have the "Zup" to be a cyan bar and "Zdn" to be a magenta bar in place of candles or if it makes it easier to add the option to have arrows or not. Can someone help with this?

Code:
#ttm_squeeze_after

# https://usethinkscript.com/threads/is-there-a-standalone-squeeze-indicator-for-upper-chart.17280/
#Is there a standalone Squeeze indicator for upper chart?
#METAL 11/26
#I am looking for a squeeze indicator that will place a dot or dots above or below the candle when the squeeze releases

# Define conditions for arrows
def sqz = ttm_squeeze().SqueezeAlert;
def during_squeeze = sqz == 1;
def after = sqz[1] == 0 and sqz == 1;
def histo = ttm_squeeze().histogram;

# Set the default color
AssignPriceColor(if during_squeeze then Color.CURRENT else Color.GRAY);

# Arrows
input arrows = yes;

plot zup = if (arrows and after and histo > histo[1]) then low * 0.99 else Double.NaN;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.GREEN);
zup.SetLineWeight(4);

plot zdwn = if (arrows and after and histo < histo[1]) then high * 1.01 else Double.NaN;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.RED);
zdwn.SetLineWeight(4);

# Points
input dots = no;

plot za = if (dots and after) then high * 1.02 else Double.NaN;
za.SetPaintingStrategy(PaintingStrategy.POINTS);
za.SetDefaultColor(Color.CYAN);
za.SetLineWeight(5);

Code:
#ttm_squeeze_after_02

# https://usethinkscript.com/threads/is-there-a-standalone-squeeze-indicator-for-upper-chart.17280/
#Is there a standalone Squeeze indicator for upper chart?
#METAL 11/26
#I am looking for a squeeze indicator that will place a dot or dots above or below the candle when the squeeze releases

def bn = barnumber();

# Define conditions for arrows
def sqz = ttm_squeeze().SqueezeAlert;
def during_squeeze = sqz == 1;
def after = sqz[1] == 0 and sqz == 1;
def histo = ttm_squeeze().histogram;

#  sqz2   -1 = down , 0 = sqz , 1 = up
def sqz2 = if bn == 1 then 0
else if (after and histo > histo[1]) then 1
else if (after and histo < histo[1]) then -1
else if sqz[1] == 0 then 0
else sqz2[1];

# Set the default color
#AssignPriceColor(if during_squeeze then Color.CURRENT else Color.GRAY);
AssignPriceColor(if sqz2 == 1 then color.cyan else if sqz2 == -1 then color.magenta else color.gray);


# Arrows
input arrows = yes;

plot zup = if (arrows and after and histo > histo[1]) then low * 0.99 else Double.NaN;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.GREEN);
zup.SetLineWeight(4);

plot zdwn = if (arrows and after and histo < histo[1]) then high * 1.01 else Double.NaN;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.RED);
zdwn.SetLineWeight(4);

# Points
input dots = no;

plot za = if (dots and after) then high * 1.02 else Double.NaN;
za.SetPaintingStrategy(PaintingStrategy.POINTS);
za.SetDefaultColor(Color.CYAN);
za.SetLineWeight(5);
#
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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