show which stocks trade outside the zone

merc2226

Member
VIP
is there a way to do labels for the Opening Range Breakout Indicator
https://usethinkscript.com/threads/opening-range-breakout-indicator-for-thinkorswim.16/
based on how many days you are looking at.

I have been doping this manually but there has t be a better way on the 5 or 2 minute chart.

label 1 it would show how many times candle closed above or below the breakout area.
label 2 how many times it crossed back below the breakout area after closing above.
label 3 how many times it ended the day above the breakout area after the breakout

This will show which stocks trade outside the zone vs others and also how many times a specific stock ends up holding above or below for the day after the actual cross and how many times it had a failed breakout.
 
Solution
is there a way to do labels for the Opening Range Breakout Indicator
https://usethinkscript.com/threads/opening-range-breakout-indicator-for-thinkorswim.16/
based on how many days you are looking at.

I have been doping this manually but there has t be a better way on the 5 or 2 minute chart.

label 1 it would show how many times candle closed above or below the breakout area.
label 2 how many times it crossed back below the breakout area after closing above.
label 3 how many times it ended the day above the breakout area after the breakout

This will show which stocks trade outside the zone vs others and also how many times a specific stock ends up holding above or below for the day after the actual cross and how many times...
is there a way to do labels for the Opening Range Breakout Indicator
https://usethinkscript.com/threads/opening-range-breakout-indicator-for-thinkorswim.16/
based on how many days you are looking at.

I have been doping this manually but there has t be a better way on the 5 or 2 minute chart.

label 1 it would show how many times candle closed above or below the breakout area.
label 2 how many times it crossed back below the breakout area after closing above.
label 3 how many times it ended the day above the breakout area after the breakout

This will show which stocks trade outside the zone vs others and also how many times a specific stock ends up holding above or below for the day after the actual cross and how many times it had a failed breakout.


see if this does what you want.
can pick how many days

labels with the rule counts

draws shapes for rules 1,2,3. they can be turned off.
.. rule 1 , white points
.. rule 2 , red triangles
.. rule 3 , green squares


Code:
# orb_breakouts01_00

#https://usethinkscript.com/threads/show-which-stocks-trade-outside-the-zone.13988/
#show which stocks trade outside the zone

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

def newday = GetDay() <> GetDay()[1];
def daycnt = if bn == 1 then 1
  else if isnan(close) then na
  else if newday then daycnt[1] + 1
  else daycnt[1];
def dayz = highestall(daycnt);

input days_of_data = 4;
def isday = (daycnt >= (dayz - days_of_data + 1));
def days_err = (days_of_data > dayz);

addlabel(1, " ", color.black);
addlabel(days_err, "========== not enough days on chart ===========", color.cyan);
addlabel(1, " ", color.black);
addlabel(1, days_of_data + " days", color.yellow);
addverticalline(!isday[1] and isday, days_of_data + "  Days", color.cyan);

input agg = AggregationPeriod.THIRTY_MIN;
def orbhi = high(period = agg);
def orblo = low(period = agg);

def hi = if isnan(daycnt) then na else if newday then orbhi else hi[1];
def lo = if isnan(daycnt) then na else if newday then orblo else lo[1];
plot h2 = hi;
plot l2 = lo;
h2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
h2.SetDefaultColor(Color.LIME);
h2.HideBubble();
l2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
l2.SetDefaultColor(Color.LIME);
l2.HideBubble();


#input BeginTime = 0930;
def endtime = 1600;
def chartagg = GetAggregationPeriod();
def chartmin = chartagg / (1000 * 60);
#addlabel(yes, chartmin + " min", color.yellow);
def endtimeadj = if endtime == 1600 then 1560 - chartmin else endtime;
#def daystart3 = if SecondsTillTime(BeginTime) == 0 and SecondsFromTime(BeginTime) == 0 then 1 else 0;
def dayend3 = if SecondsTillTime(endtimeadj) == 0 and SecondsFromTime(endtimeadj) == 0 then 1 else 0;


#label 1 it would show how many times candle closed above or below the breakout area.
def r1up = if !isday then 0 else (close > hi);
def r1dwn = if !isday then 0 else (close < lo);
def r1 = r1up or r1dwn;
#label 2 how many times it crossed back below the breakout area after closing above.
#def r2 = if newday then 0 else close crosses below hi;
def r2 = if newday or !isday or bn == 1 then 0 else (close crosses below hi);
#label 3 how many times it ended the day above the breakout area after the breakout
def r3 = if newday or !isday then 0 else (close > hi and dayend3);

def r1cnt = if !isday or bn == 1 then 0 else if r1 then r1cnt[1] + 1 else r1cnt[1];
def r2cnt = if !isday or bn == 1 then 0 else if r2 then r2cnt[1] + 1 else r2cnt[1];

addlabel(1, "Rule 1 count: " + r1cnt, color.white);
addlabel(1, "Rule 2 count: " + r2cnt, color.red);
addlabel(1, "Rule 3: " + r3, color.green);

#--------------------


input test1 = no;
addchartbubble(test1, low,
 r1 + "\n" +
 r1cnt + "\n" +
 r2 + "\n" +
 r2cnt + "\n" +
 r3
, color.yellow, no);


input test_rule1 = yes;
plot zr1a = if test_rule1 and r1up then high * 1.001 else na;
zr1a.SetPaintingStrategy(PaintingStrategy.points);
zr1a.SetDefaultColor(Color.white);
zr1a.SetLineWeight(3);
zr1a.HideBubble();
plot zr1b = if test_rule1 and r1dwn then low * 0.999 else na;
zr1b.SetPaintingStrategy(PaintingStrategy.points);
zr1b.SetDefaultColor(Color.white);
zr1b.SetLineWeight(3);
zr1b.HideBubble();


input test_rule2 = yes;
plot zr2 = if test_rule2 and r2 then low * 0.999 else na;
zr2.SetPaintingStrategy(PaintingStrategy.triangles);
zr2.SetDefaultColor(Color.red);
zr2.SetLineWeight(4);
zr2.HideBubble();


input test_rule3 = yes;
plot zr3 = if test_rule3 and r3 then high * 1.002 else na;
zr3.SetPaintingStrategy(PaintingStrategy.squares);
zr3.SetDefaultColor(Color.green);
zr3.SetLineWeight(4);
zr3.HideBubble();


input show_day_end = no;
plot zbuy = if show_day_end and dayend3 then close else na;
zbuy.SetPaintingStrategy(PaintingStrategy.points);
zbuy.SetDefaultColor(Color.white);
zbuy.SetLineWeight(3);
zbuy.HideBubble();

#

FAEBhvv.jpg
 
Solution
Thank you so much, 2 things I see not working right:
rule 1 is counting every candle above the line, it would be better if it counted 1 every time it crossed outside of the zone like rule 2. It counts every time it crosses back into the zone which is great, rule 1 should be the same only outside of the zone.

the shortside isn't counting at all. can we have it count the same way with the totals equaling both the short and long side combined?

thanks again, this is so close.
 

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
259 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