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