GlobeX or Overnight High / Low For ThinkOrSwim

Cybersloth

Member
Automatically Labelling Afterhours/Overnight Market Highs & Lows For ThinkOrSwim
Was in the Thinkscript Lounge over at TOS and stumbled onto this script helpfully provided by Mobius to a user inquiring about after-hours market highs and lows. For the script to function, time needs to be set to an intraday increment with afterhours checked ON


Code:
# GlobeX or Overnight High / Low
# Mobius
# V01.2012

input PlotOverNightExtremes = yes;

def o = open;
def h = high;
def l = low;
def c = close;
def bar = barNumber();
def Intraday = GetAggregationPeriod() < AggregationPeriod.DAY;
def RTH = getTime() >= regularTradingStart(getYYYYMMDD()) and
          getTime() <= regularTradingEnd(getYYYYMMDD());
def ONhigh = if !RTH and RTH[1]
             then h
             else if !RTH and
                     h > ONhigh[1]
                  then h
                  else ONhigh[1];
def ONhighBar = if !RTH and h == ONhigh
                then BarNumber()
                else ONhighBar[1];
def ONlow = if !RTH and RTH[1]
            then l
            else if !RTH and l < ONlow[1]
                 then l
            else ONlow[1];
def ONlowBar = if !RTH and l == ONlow
               then BarNumber()
               else ONlowBar[1];
def OverNightHigh = if BarNumber() == HighestAll(ONhighBar)
                    then h
                    else OverNightHigh[1];
def OverNightLow = if BarNumber() == HighestAll(ONlowBar)
                   then l
                   else OverNightLow[1];
plot ONH = if Intraday and OverNightHigh > 0
           then OverNightHigh
           else Double.NaN;
ONH.SetHiding(!PlotOverNightExtremes);
ONH.SetPaintingStrategy(PaintingStrategy.SQUARES);
ONH.SetDefaultColor(Color.BLUE);
plot ONL = if Intraday and OverNightLow > 0
           then OverNightLow
           else Double.NaN;
ONL.SetHiding(!PlotOverNightExtremes);
ONL.SetPaintingStrategy(PaintingStrategy.SQUARES);
ONL.SetDefaultColor(Color.GRAY);
AddChartBubble(bar == ONhighBar and PlotOverNightExtremes, ONH, "ONH", ONH.TakeValueColor());
AddChartBubble(bar == ONlowBar and PlotOverNightExtremes, ONL, "ONL", ONL.TakeValueColor(), 0);
# End Code Overnight (GlobeX) high and low
 
Last edited by a moderator:
@Cybersloth - this script is awesome, however is there a way to have it plot from 1800 hours to 9:30? I want it to show me the high and low for /ES, /NQ, and /YM beginning at 6pm EST(1800) and end at 9:30EST. Thanks in advanced for any help you can offer.
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
451 Online
Create Post

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