Opening Range (ORB) Watchlist Column for ThinkorSwim

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

Thanks for sharing. I am trying to figure out the lower studies. I could not understand the lower studies dots and triangles. in the TMO bar. Can you please guide me to the post i can get grip of it. Thanks
@HighBredCloud can probably explain it better to you. But they are multi period Fisher at the top, super trend, and trend magic at the bottom. Here is the working version on the lower time frame. https://tos.mx/NUeALnn and I changed the name of it to reflect HBC's contribution. BTW, If you try to go it to say a 15 minute- daily time frames you need to make sure that ALL the timeframes are updated.
 
I am creating an alert column in my scan and I need to first define to use later the High during the first 15 minutes of the regular trading session of that day. I though gettime would make it work but having no luck. I also tried using def Active = secondsTillTime(0930) > 0 and secondsFromTime(0945) > 0 in a formula, but that just makes the column active during that time period. Suggestions?
 
Below are two custom watchlist columns for the Opening Range Breakout indicator. Add either one to your watchlist of stocks and it will tell you which tickers are currently breaking out, breaking down, or within the trading range of the first 30mins.

Both work the same way - just visually different. First one was created by Mobius and the second one by @WalkingBallista.

e2W9TwY.png


Mobius ThinkScript Lounge 2017

Rich (BB code):
# ORB Watch List Column
input StartTime = 0930;
input EndTime = 1000;
def h = high;
def l = low;
def c = close;
def ORActive = if SecondsFromTime(StartTime) > 0 and
                   SecondsTillTime(EndTime) >= 0
                then 1
                else 0;
def ORH = if ORActive and !ORActive[1]
           then h
           else if ORActive and
                   h > ORH[1]
                then h
                else ORH[1];
def ORL = if ORActive and !ORActive[1]
           then l
           else if ORActive and
                   l < ORL[1]
                then l
                else ORL[1];
def ORhigh = if !ORActive
              then ORH
               else Double.NaN;
def ORlow = if !ORActive
              then ORL
              else Double.NaN;
AddLabel(1, if close > ORhigh
             then "Above"
             else if close < ORlow
                  then "Below"
                  else "Inside",
             if close > ORhigh
             then color.green
             else if close < ORlow
                  then color.red
                  else color.yellow);

WalkingBallista's thinkScript Code

Code:
# 30 min opening range
# Robert Payne
# WalkingBallista Watchlist

def OpenRangeMinutes = 30;
def MarketOpenTime = 0930;
input ShowTodayOnly = yes;

def Today = if GetDay() == GetLastDay() then 1 else 0;
def FirstMinute = if SecondsFromTime(MarketOpenTime) < 60 then 1 else 0;
def OpenRangeTime = if SecondsFromTime(MarketOpenTime) < 60 * OpenRangeMinutes then 1 else 0;

def ORHigh =  if FirstMinute then high else if OpenRangeTime and high > ORHigh[1] then high else ORHigh[1];
def ORLow = if FirstMinute then low else if OpenRangeTime and low < ORLow[1] then low else ORLow[1];

def OpenRangeHigh = if ShowTodayOnly and !Today then Double.NaN else if !OpenRangeTime then ORHigh else Double.NaN;
def OpenRangeLow = if ShowTodayOnly and !Today then Double.NaN else if !OpenRangeTime then ORLow else Double.NaN;

def dailyRange = high(period = "day" )[1] - low(period = "day" )[1];
def range = Average(dailyRange, 10);

plot status = if close > OpenRangeHigh then 1 else if close < OpenRangeLow then 0 else -1;
status.AssignValueColor(if status == 1 then Color.Dark_Green else if status == 0 then Color.Dark_Red else Color.Dark_Orange);
AssignBackgroundCOlor(if status == 1 then Color.Dark_Green else if status == 0 then Color.Dark_Red else Color.Dark_Orange);

Shareable Links

@BenTen contributed to this post.
Hi Markos,
Do you have a watchlist column script to indicate whether the stock breaks prior day high or prior day low? If you have it, could you share it with me?

Thanks.
 
I am curious if someone can assist. I have this watchlist script for an Open Range Breakout High. I am trying to reverse the instructions to plot the Open Range Breakout Low to the downside. However, once I remove the # the dominant script the Red takes over.

Code:
def Active = SecondsFromTime(0930) > 0 and SecondsTillTime(1000) >= 0;
def ORBH = if Active and !Active[1] then high else if Active and high > ORBH[1] then high else ORBH[1];
plot scan = !Active and close > ORBH;

assignbackgroundcolor(if ORBH then color.green else color.black);

AddLabel (yes, if ORBH then "ORBH" else " ");

AssignBackgroundColor (if ORBH then color.GREEN else color.LIGHT_GRAY);


#def Active1 = SecondsFromTime(0930) > 0 and SecondsTillTime(1000) >= 0;
#def ORBL = if Active1 and !Active1[1] then low else if Active1 and low < ORBL[1] then low else ORBL[1];
#def scan1 = !Active1 and close < ORBL;

#AddLabel (yes, if ORBL then "ORBL" else " ");

#AssignBackgroundColor (if ORBL then color.RED else color.LIGHT_GRAY);
 
@markos Can you tell me if I need to setup which time frame or aggregation? 5 min, 15 min, 30 min? Thanks.

@VicD Great it works ! However, can we create an alert too by messaging through the bell in TOS? Thanks.
 
How about instead of showing ABOVE or BELOW or INSIDE...there is a bar count that displays GREEN for ABOVE or RED for BELOW the ORB that can be sorted...That way you can see what stock looks good based on how many bars are ABOVE or BELOW the ORB to get into from the watchlist...Anyone is able to do that?
 
@HighBredCloud Interesting idea. @diazlaz and I were talking about this last week. Going to tag him in here just in case he has a watchlist column for that.

IF anyone could do something like this I know he'd be more than fully capable if his time permits. This would be the best way to search for stocks ABOVE or BELOW the ORB that are generated from the scanner and are in the watchlist if you can see the bar count of how many bars are ABOVE or BELOW the ORB...sorting it would allow you to get in at bar 1 that would indicate the most recent cross ABOVE or BELOW ORB such as a reversal or pull back...or bar 100+ that would indicate a steady trend in a given direction of the ORB...
 
@BenTen @HighBredCloud I don't wish to barge in, but earlier this month I added a count to Mobius' ORB watchlist column, but was still using the original AddLabel function. After seeing your comments here I realized that it was a wise idea to use the plot function instead. Here's my modified watchlist code that I changed to use plot instead of AddLabel.

Code:
# Watchlist ORB Status
# Mobius
# V01 using getTIme()
# Note: Column Aggregation MUST be 30min or less
# Pensar - 07/06/2020 - modified to count bars above/below Opening Range
#        - 07/31/2020 - changed code to use plot instead of AddLabel
#                       so that column can be sorted numerically

# The input below will show the bar count when inside the Opening Range
# if set to "yes", otherwise it will display "NaN".
input show_inside_bar_count = yes;

def Active = getTime() >= RegularTradingStart(getYYYYMMDD()) and
             getTime() <= RegularTradingStart(getYYYYMMDD()) +    
             AggregationPeriod.Thirty_Min;
def hh = if Active and !Active[1] then high
         else if Active and high > hh[1] then high
         else hh[1];
def ll = if Active and !Active[1] then low
         else if Active and low < ll[1] then low
         else ll[1];
def current = if between(close, ll, hh) then 0
              else if close > hh then 1
              else if close < ll then -1
              else double.nan;
def n1 = current == 1;
def n2 = current == -1;
def n3 = current == 0;
def count_up = if n1 and !n1[1] then 1 else count_up[1]+1;
def count_dn = if n2 and !n2[1] then 1 else count_dn[1]+1;
def count_in = if show_inside_bar_count then 
               if n3 and !n3[1] then 1 
               else count_in[1]+1
               else double.nan;

plot Number = if n1 then count_up
              else if n2 then count_dn
              else count_in;
     Number.AssignValueColor(if n1 then color.green
                             else if n2 then color.red
                             else color.yellow);
AssignBackgroundColor(if n1 then createColor(51,102,0)
                      else if n2 then createColor(155,0,0)
                      else createColor(180,180,5));
# End Code ORB Status
 
Last edited:
@Pensar Thank You! Looking at it now in after hours market...Everything seem to be GOOD...I did notice that some stocks come up with NaN...this could be because the market is closed and it just didn't update...The rest of it seems to plot correctly...I can't wait to test this out in a live market...This will be a great way to sort through the results in a watchlist.
 
@HighBredCloud I run it at a 5 min aggregation with extended hours unchecked on the watchlist column. I've not noticed any problems, but if I do I'll be sure to post. :)
 
@HighBredCloud I run it at a 5 min aggregation with extended hours unchecked on the watchlist column. I've not noticed any problems, but if I do I'll be sure to post. :)

I just unchecked the extended hours...and still the same thing...it must be because the market is closed...BUT here is what I am referring to on my end...just incase take a look at the stocks with the NaN on your end to see if you get the same thing as I do...


I am further looking into the stocks that should be above the ORB from today...I noticed that the following from my list do not match up up with the bar count on the LONG side...there may be more from that list...so far I just caught these 3...Figured I would share this just incase something is amiss and needs to be fixed. Short side seemed OK...but I would need to look through everything to be sure...and again not sure IF the after hours has anything to do with this or not. I also unchecked the Extended Hours and also set it to 5 min...I am using slightly different ORB that Robert Payne made...but its also set to 5 min so that shouldn't be an issue....



 
@HighBredCloud Thanks for the picture. (y) I ran through the stocks and can confirm that the watchlist is displaying correctly when it says "NaN". When I modified the code, I only counted the bars above the Opening Range and below the OR. When price is inside/between the high and low of the OR, it plots yellow and displays "NaN".

I added a yes/no input and a third count for the bars when inside the Opening Range, and updated the above code.
 
Last edited:
@HighBredCloud Thanks for the picture. (y) I ran through the stocks and can confirm that the watchlist is displaying correctly when it says "NaN". When I modified the code, I only counted the bars above the Opening Range and below the OR. When price is inside/between the high and low of the OR, it plots yellow and displays "NaN".

I added a third count for the bars when inside the Opening Range and updated the above code.

Sounds good...I also saw the mistake that I made...In your original code the aggregation was set to 30 min...I only changed to 5 min on the ThinkScript Editor...and not in the actual code...

I was literally counting the bars on the 5 min chart and it appeared as if it was the 30 min...and it was...I guess that's what I get for not looking at the code...oh well not much of a coder but hopefully others who read this will need to change the aggregation time in the actual script itself if anyone wants to run 5 min ORB or anything different...

Thanks again for your help in this...
 
Sounds good...I also saw the mistake that I made...In your original code the aggregation was set to 30 min...I only changed to 5 min on the ThinkScript Editor...and not in the actual code...

I was literally counting the bars on the 5 min chart and it appeared as if it was the 30 min...and it was...I guess that's what I get for not looking at the code...oh well not much of a coder but hopefully others who read this will need to change the aggregation time in the actual script itself if anyone wants to run 5 min ORB or anything different...

Thanks again for your help in this...
@HighBredCloud Sure, glad to help. The 30 min agg period was coded in by Mobius (I'm guessing to prevent it from being used on higher watchlist aggregations, since the ORB trading method works off the 30 minute opening range). I have not changed it in my code, and I would recommend not doing so. Just set your column aggregation to any aggregation 30 min or lower and it should work fine. ;)
 
@HighBredCloud Sure, glad to help. The 30 min agg period was coded in by Mobius (I'm guessing to prevent it from being used on higher watchlist aggregations, since the ORB trading method works off the 30 minute opening range). I have not changed it in my code, and I would recommend not doing so. Just set your column aggregation to any aggregation 30 min or lower and it should work fine. ;)

Correct me if I am wrong...but IF I do not change the 30 min aggregation in the scrip to 5 min...and I only change the column to 5 min...the bars for the opening range will still be counted as if they were on a 30 min chart using a 30 min ORB instead of 5 min ORB...That was my original issue...After changing to 5 min everything seems to be working fine. In the pictures that I provided I displayed the 5 min ORB on my chart...I guess its a personal preference on what to set the ORB to...some prefer 5 min...others 15 min and Mobius suggests 30 min ORB...Either way...this works now for me and will be a great help in sorting...

What I would like to know now from anyone with experience or a strategy for ORB is what else to combine this with? Too many times I have engaged in trades where I thought the ORB was breaking out/down only to have it pull back on me and continue on inside day etc...Anyone have any recommendations on what to pair the ORB with? I have been playing with the idea of Trend Magic Indicator set to 1 hour...followed by another instance of Trend Magic set to 15 min...The idea is to trade when both the 1 hour and 15 min are going in the direction of the ORB...not sure if there is a better way that someone has found. I chose the Trend Magic because its a line that needs to be crossed essentially just like the ORB...not a lagging indicator.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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