ORB End Time

I'm struggling to add an end time to the ORB
https://usethinkscript.com/threads/opening-range-breakout-indicator-for-thinkorswim.16/

Ideally, I'll be layering three of these for the US, UK, and HK sessions but at the moment the clouds etc. overlap. I tried adding a defined Market End to the 'def today' section but no luck.

that study probably wasn't made to span midnight.

a couple things to look at
https://usethinkscript.com/threads/average-daily-range-indicator-for-thinkorswim.244/#post-66296

https://usethinkscript.com/threads/ict-time-labels.15632/

https://usethinkscript.com/threads/highest-high-and-lowest-low-two-times-frames.15006/#post-123591
 

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

I'm struggling to add an end time to the ORB
https://usethinkscript.com/threads/opening-range-breakout-indicator-for-thinkorswim.16/

Ideally, I'll be layering three of these for the US, UK, and HK sessions but at the moment the clouds etc. overlap. I tried adding a defined Market End to the 'def today' section but no luck.

  • I faced a similar problem as you
  • I added new input time, please see script on this post
  • I didn;t need the ATR targets etc., so I removed the code from my version
  • If you are adding this feature, then you will have to selectively add code
  • Notice the code around RTH End, you would want to change that for each session etc, /per copy
  • Hope this helps.



Rich (BB code):
declare hide_on_daily;
declare once_per_bar;

input OrMeanS  = 0930.0; #hint OrMeanS: Begin Mean Period. Usually Market Open EST.
input OrMeanE  = 0935.0; #hint OrMeanE: End Mean period. Usually End of first bar.
input OrBegin  = 0930.0; #hint OrBegin: Beginning for Period of Opening Range Breakout.
input OrEnd    = 1000.0; #hint OrEnd: End of Period of Opening Range Breakout.
input RTHEnd   = 1615.0;
input CloudOn  = yes;     #hint CloudOn: Clouds Opening Range.
input ShowTodayOnly = {default "No", "Yes"};
input showLabels = no;
def h = high;
def l = low;
def c = close;
def bar = BarNumber();
def s = ShowTodayOnly;
def ORActive = if SecondsTillTime(OrMeanE) > 0 and
                    SecondsFromTime(OrMeanS) >= 0
                 then 1
                 else 0;
def today = if s == 0
              or GetDay() == GetLastDay() and
                 SecondsFromTime(OrMeanS) >= 0
              then 1
              else 0;
def ORHigh = if ORHigh[1] == 0
               or ORActive[1] == 0 and
                  ORActive == 1
               then h
               else if ORActive and
                       h > ORHigh[1]
               then h
               else ORHigh[1];
def ORLow = if ORLow[1] == 0
              or ORActive[1] == 0 and
                 ORActive == 1
              then l
              else if ORActive and
                      l < ORLow[1]
              then l
              else ORLow[1];
def ORWidth = ORHigh - ORLow;
def na = Double.NaN;
def ORHA = if ORActive
             or today < 1
             then na
             else ORHigh;
def ORLA = if ORActive
             or today < 1
             then na
             else ORLow;
def O = ORHA - Round(((ORHA - ORLA) / 2) / TickSize(), 0) * TickSize();
def ORActive2 = if SecondsTillTime(OrEnd) > 0 and
                     SecondsFromTime(OrBegin) >= 0
                  then 1
                  else 0;

def RTHActive = if SecondsTillTime(RthEnd) > 0 and
                     SecondsFromTime(OrBegin) >= 0
                  then yes
                  else no;

def ORHigh2 = if ORHigh2[1] == 0
                  or ORActive2[1] == 0 and
                     ORActive2 == 1
                then h
                else if ORActive2 and
                        h > ORHigh2[1]
                then h
                else ORHigh2[1];
def ORLow2 = if ORLow2[1] == 0
                or ORActive2[1] == 0 and
                   ORActive2 == 1
               then l
               else if ORActive2 and
                       l < ORLow2[1]
               then l
               else ORLow2[1];
def ORWidth2 = ORHigh2 - ORLow2;
def TimeLine = if SecondsTillTime(OrEnd) == 0 
                 then 1
                 else 0;
def ORmeanBar = if !ORActive and ORActive[1]
                  then BarNumber()
                  else ORmeanBar[1];
def ORendBar = if !ORActive2 and ORActive2[1]
                 then BarNumber()
                 else ORendBar[1];
def ORL = If (O == 0 , na, O);
plot ORLext = if BarNumber() >= HighestAll(ORmeanBar)
              then HighestAll(if IsNaN(c[-1])
                              then ORL[1]
                              else Double.NaN)
              else Double.NaN;
ORLext.SetDefaultColor(Color.YELLOW);
ORLext.SetStyle(Curve.LONG_DASH);
ORLext.SetLineWeight(3);
ORLext.HideTitle();
def ORH2 = if ORActive2
             or today < 1
             then na
             else ORHigh2;
plot ORH2ext = if BarNumber() >= HighestAll(ORendBar)
               then HighestAll(if IsNaN(c[-1])
                               then ORH2[1]
                               else Double.NaN)
               else Double.NaN;
ORH2ext.SetDefaultColor(Color.GREEN);
ORH2ext.SetStyle(Curve.LONG_DASH);
ORH2ext.SetLineWeight(3);
ORH2ext.HideTitle();
def ORL2 = if ORActive2
               or today < 1
             then na
             else ORLow2;
plot ORL2ext = if BarNumber() >= HighestAll(ORendBar)
               then HighestAll(if IsNaN(c[-1])
                               then ORL2[1]
                               else Double.NaN)
               else Double.NaN;
ORL2ext.SetDefaultColor(Color.RED);
ORL2ext.SetStyle(Curve.LONG_DASH);
ORL2ext.SetLineWeight(3);
ORL2ext.HideTitle();
def RelDay = (ORL - ORL2) / (ORH2 - ORL2);
def dColor = if RelDay > .5
               then 5
               else if RelDay < .5
                    then 6
               else 4;
def pos = (ORH2 - ORL2) / 10;
plot d1 = If (TimeLine , ORH2, na);
plot d2 = If (TimeLine , ORH2 - ( pos * 2), na);
plot d3 = If (TimeLine , ORH2 - ( pos * 3), na);
plot d4 = If (TimeLine , ORH2 - ( pos * 4), na);
plot d5 = If (TimeLine , ORH2 - ( pos * 5), na);
plot d6 = If (TimeLine , ORH2 - ( pos * 6), na);
plot d7 = If (TimeLine , ORH2 - ( pos * 7), na);
plot d8 = If (TimeLine , ORH2 - ( pos * 8), na);
plot d9 = If (TimeLine , ORH2 - ( pos * 9), na);
plot d10 = If (TimeLine , (ORL2), na);
d1.SetPaintingStrategy(PaintingStrategy.POINTS);
d2.SetPaintingStrategy(PaintingStrategy.POINTS);
d3.SetPaintingStrategy(PaintingStrategy.POINTS);
d4.SetPaintingStrategy(PaintingStrategy.POINTS);
d5.SetPaintingStrategy(PaintingStrategy.POINTS);
d6.SetPaintingStrategy(PaintingStrategy.POINTS);
d7.SetPaintingStrategy(PaintingStrategy.POINTS);
d8.SetPaintingStrategy(PaintingStrategy.POINTS);
d9.SetPaintingStrategy(PaintingStrategy.POINTS);
d10.SetPaintingStrategy(PaintingStrategy.POINTS);
d1.AssignValueColor(GetColor(dColor));
d2.AssignValueColor(GetColor(dColor));
d3.AssignValueColor(GetColor(dColor));
d4.AssignValueColor(GetColor(dColor));
d5.AssignValueColor(GetColor(dColor));
d6.AssignValueColor(GetColor(dColor));
d7.AssignValueColor(GetColor(dColor));
d8.AssignValueColor(GetColor(dColor));
d9.AssignValueColor(GetColor(dColor));
d10.AssignValueColor(GetColor(dColor));
d1.HideBubble();
d2.HideBubble();
d3.HideBubble();
d4.HideBubble();
d5.HideBubble();
d6.HideBubble();
d7.HideBubble();
d8.HideBubble();
d9.HideBubble();
d10.HideBubble();
d1.HideTitle();
d2.HideTitle();
d3.HideTitle();
d4.HideTitle();
d5.HideTitle();
d6.HideTitle();
d7.HideTitle();
d8.HideTitle();
d9.HideTitle();
d10.HideTitle();
DefineGlobalColor("ORBLong", Color.Green);
DefineGlobalColor("ORBShort", Color.Red);
AddCloud(if CloudOn == yes and RTHActive
         then ORL
         else Double.NaN,  ORL2,
        GlobalColor("ORBShort"), 
        GlobalColor("ORBShort"));
#CreateColor(244, 83, 66));
AddCloud(if CloudOn == yes and RTHActive
         then ORL
         else Double.NaN
       , ORH2,         GlobalColor("ORBLong"), 
        GlobalColor("ORBLong"));
#CreateColor(66, 244, 131), CreateColor(66, 244, 131));
# Begin Risk Algorithm
# First Breakout or Breakdown bars
def Bubbleloc1 = IsNaN(close[-5]) and !IsNaN(close[-4]);
def BreakoutBar = if ORActive
                    then Double.NaN
                    else if !ORActive and c crosses above ORH2
                         then bar
                         else if !IsNaN(BreakoutBar[1]) and c crosses ORH2
                              then BreakoutBar[1]
                    else BreakoutBar[1];
# End Code ORB 


Screenshot_1.png
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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