GlobeX or Overnight High / Low

Chuck

Moderator
Staff member
Platform
  1. Thinkorswim
7Zz3A2H.png
Code:
# GlobeX or Overnight High / Low



input PlotOverNightExtremes = yes;

def o = open;
def h = high;
def l = low;
def c = close;
def bar = barNumber();
def Intraday = if GetAggregationPeriod() < 86400000
               then 1
               else 0;
def OverNightActive =  if (SecondsFromTime(1700) >= 0 and
                           SecondsTillTime(0000) <= 0)
                          or
                          (SecondsFromTime(0000) >= 0 and
                           SecondsFromTime(0930) < 0)
                        then 1
                       else Double.NaN;
def ONhigh = if !IsNaN(OverNightActive) and IsNaN(OverNightActive[1])
             then h
             else if !IsNaN(OverNightActive) and
                     h > ONhigh[1]
                  then h
                  else ONhigh[1];
def ONhighBar = if !IsNaN(OverNightActive) and h == ONhigh
                then BarNumber()
                else ONhighBar[1];
def ONlow = if !IsNaN(OverNightActive) and IsNaN(OverNightActive[1]) and IsNaN(ONlow[1])
            then l
            else if IsNaN(OverNightActive)
                 then Double.NaN
            else if !IsNaN(OverNightActive) and
                    l < ONlow[1]
                 then l
                 else ONlow[1];
def ONlowBar = if !IsNaN(OverNightActive) 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
           then OverNightHigh
           else Double.NaN;
ONH.SetHiding(!PlotOverNightExtremes);
ONH.SetPaintingStrategy(PaintingStrategy.SQUARES);
ONH.SetDefaultColor(Color.BLUE);
plot ONL = if Intraday
           then OverNightLow
           else Double.NaN;
ONL.SetHiding(!PlotOverNightExtremes);
ONL.SetPaintingStrategy(PaintingStrategy.SQUARES);
ONL.SetDefaultColor(Color.GRAY);
AddChartBubble(bar == ONhighBar and PlotOverNightExtremes, ONH, "ONH", Color.BLUE);
AddChartBubble(bar == ONlowBar and PlotOverNightExtremes, ONL, "ONL", Color.GRAY, 0);
 
Last edited:

krahsloop

New member
Tried 5 other ONH/ONL scripts from various other sources and none could get the after hours high/low correct. Thanks so much for sharing this!
 

Ghost

Member
Added the overnight open, arguably the strongest point to look at.
Code:
# GlobeX or Overnight High / Low

input agg = AggregationPeriod.DAY;
input PlotOverNightExtremes = yes;


def h = high;
def l = low;
def c = close;
def bar = BarNumber();
def Intraday = if GetAggregationPeriod() < 86400000
               then 1
               else 0;
def OverNightActive =  if (SecondsFromTime(1700) >= 0 and
                           SecondsTillTime(0000) <= 0)
                          or
                          (SecondsFromTime(0000) >= 0 and
                           SecondsFromTime(0930) < 0)
                        then 1
                       else Double.NaN;
def ONhigh = if !IsNaN(OverNightActive) and IsNaN(OverNightActive[1])
             then h
             else if !IsNaN(OverNightActive) and
                     h > ONhigh[1]
                  then h
                  else ONhigh[1];
def ONhighBar = if !IsNaN(OverNightActive) and h == ONhigh
                then BarNumber()
                else ONhighBar[1];
def ONlow = if !IsNaN(OverNightActive) and IsNaN(OverNightActive[1]) and IsNaN(ONlow[1])
            then l
            else if IsNaN(OverNightActive)
                 then Double.NaN
            else if !IsNaN(OverNightActive) and
                    l < ONlow[1]
                 then l
                 else ONlow[1];
def ONlowBar = if !IsNaN(OverNightActive) 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
           then OverNightHigh
           else Double.NaN;
ONH.SetHiding(!PlotOverNightExtremes);
ONH.SetPaintingStrategy(PaintingStrategy.SQUARES);
ONH.SetDefaultColor(Color.BLUE);
plot ONL = if Intraday
           then OverNightLow
           else Double.NaN;
ONL.SetHiding(!PlotOverNightExtremes);
ONL.SetPaintingStrategy(PaintingStrategy.SQUARES);
ONL.SetDefaultColor(Color.GRAY);
AddChartBubble(bar == ONhighBar and PlotOverNightExtremes, ONH, "ONH", Color.BLUE);
AddChartBubble(bar == ONlowBar and PlotOverNightExtremes, ONL, "ONL", Color.GRAY, 0);

plot ONO = open (period = agg);
ONO.setPaintingStrategy(PaintingStrategy.SQUARES);
ONO.setDefaultColor(color.black);
 
Last edited:

krahsloop

New member
Thanks for this mod! It does look very useful...but I don't quite understand. Would you be willing to explain or point me to some information on the significance of the overnight open? I'm still learning! In any case, many thanks again for your contribution!
 

Ghost

Member
Thanks for this mod! It does look very useful...but I don't quite understand. Would you be willing to explain or point me to some information on the significance of the overnight open? I'm still learning! In any case, many thanks again for your contribution!
In the Futures, it's technically not the overnight open but the normal open worldwide, it is just my theory that all algos calculate all their info from the open of the bar, it would only make sense to elaborate on future data you would need initial data. You will see a lot of people using the previous close and pushing it one bar forward when all that is in 99% of cases is just the open of the new bar formed.


An example above is the opening of the beginning of each year extending, as you can see from just observation, it is very significant. Just like the significance of the IPO price of a stock and how markets will usually dump it once a stock goes below its IPO. Simply put, the open is the first bit of data the algos will ever use in calculating future data. My research has gone way beyond this, I'm a fib guy, and it has significantly made headwinds the past couple of months just by realizing this concept.
 
Last edited:
Top