Premarket After-market For ThinkOrSwim

This indicator for ThinkorSwim will automatically plot overnight High and Low on your chart. In addition, the indicator will also include Fibonacci retracement based on the highest and lowest values from pre-market.

This can be useful for anyone who often plays pre-market breakout or breakdown. You may want to check out this strategy as well.

uUiRGl0.png


thinkScript Code

Rich (BB code):
# GlobeX or Overnight High / Low with Fibonacci Values 

# Mobius 

# V01.2012 

input PlotOverNightExtremes = yes;

input coeff_1 = .236;

input coeff_2 = .327;

# gmh: added the rest of the Fibs 

input coeff_3 = .500;

input coeff_4 = .618;

input coeff_5 = .789;

input coeff_6 = .882;



def o = open;

def h = high;

def l = low;

def c = close;

def v = volume;

def bar = BarNumber();

def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());

def vol = if GlobeX and !Globex[1]

          then v

          else if GlobeX

               then vol[1] + v

               else Double.NaN;

def GlobeX_Volume = vol;

def ONhigh = if GlobeX and !Globex[1]

             then h

             else if Globex and

                     h > ONhigh[1]

                     then h

                  else ONhigh[1];

def ONhighBar = if GlobeX and h == ONhigh

                then Bar

                else double.nan;

def ONlow = if GlobeX and !GlobeX[1]

            then l

            else if GlobeX and

                    l < ONlow[1]

            then l

                 else ONlow[1];

def ONlowBar = if GlobeX and l == ONlow

               then Bar

               else double.nan;

def OverNightHigh = if BarNumber() == HighestAll(ONhighBar)

                    then ONhigh

                    else OverNightHigh[1];

def OverNightLow = if BarNumber() == HighestAll(ONlowBar)

                   then ONlow

                   else OverNightLow[1];

plot ONH = if OverNightHigh > 0

           then OverNightHigh

           else Double.NaN;

     ONH.SetHiding(!PlotOverNightExtremes);

     ONH.SetPaintingStrategy(PaintingStrategy.SQUARES);

     ONH.SetDefaultColor(Color.BLUE);

     ONH.HideBubble();

     ONH.HideTitle();

plot ONL = if OverNightLow > 0

           then OverNightLow

           else Double.NaN;

     ONL.SetHiding(!PlotOverNightExtremes);

     ONL.SetPaintingStrategy(PaintingStrategy.SQUARES);

     ONL.SetDefaultColor(Color.LIGHT_GRAY);

     ONL.HideBubble();

     ONL.HideTitle();



def MaxBar = Max(HighestAll(ONhighBar), HighestAll(ONlowBar));



plot coeff1 = if HighestAll(ONhighBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then ((OverNightHigh - OverNightLow) * coeff_1) + OverNightLow

              else if HighestAll(ONlowBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then OverNightHigh - ((OverNightHigh - OverNightLow) * coeff_1)

              else double.nan;

plot coeff2 = if HighestAll(ONhighBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then ((OverNightHigh - OverNightLow) * coeff_2) + OverNightLow

               else if HighestAll(ONlowBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then OverNightHigh - ((OverNightHigh - OverNightLow) * coeff_2)

              else double.nan;

plot coeff3 = if HighestAll(ONhighBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then ((OverNightHigh - OverNightLow) * coeff_3) + OverNightLow

              else if HighestAll(ONlowBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then OverNightHigh - ((OverNightHigh - OverNightLow) * coeff_3)

              else double.nan;

plot coeff4 = if HighestAll(ONhighBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then ((OverNightHigh - OverNightLow) * coeff_4) + OverNightLow

              else if HighestAll(ONlowBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then OverNightHigh - ((OverNightHigh - OverNightLow) * coeff_4)

              else double.nan;

plot coeff5 = if HighestAll(ONhighBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then ((OverNightHigh - OverNightLow) * coeff_5) + OverNightLow

              else if HighestAll(ONlowBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then OverNightHigh - ((OverNightHigh - OverNightLow) * coeff_5)

              else double.nan;

plot coeff6 = if HighestAll(ONhighBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then ((OverNightHigh - OverNightLow) * coeff_6) + OverNightLow

              else if HighestAll(ONlowBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then OverNightHigh - ((OverNightHigh - OverNightLow) * coeff_6)

              else double.nan;

# 

# End Code GlobeX High Low with Fibs 

Shareable Link

https://tos.mx/oNY5Yw

Hi, is there a version of this that includes yesterday's after hours high/low in the calculation? Everything I've found seems to only include premarket data. For example if yesterday's after hours high was higher than today's premarket high, then the indicator will plot the after hours high.
 
Hi MerryDay thanks so much for your response. I'm not sure if my question was clear, and I realize it may not actually apply to this study specifically. This seems to show highs and lows for regular markets hours only, what I'm looking for is something that includes/has the option to include after hours and pre market prices when plotting the low/high. The closest I've found is a study that will plot a line at the pre market high or low, but I haven't seen anything that will include after hours prices to determine the high/low point, for example if an equity went lower than both the close and the premarket, then it would be at that after hours low where the line was plotted. Basically what I'm trying to find/create is a standalone study that plots the overnight high and overnight low, taking into account both yesterday's after hours and today's premarket. Please pardon the clunky description, I hope that makes sense!
 
Hi MerryDay thanks so much for your response. I'm not sure if my question was clear, and I realize it may not actually apply to this study specifically. This seems to show highs and lows for regular markets hours only, what I'm looking for is something that includes/has the option to include after hours and pre market prices when plotting the low/high. The closest I've found is a study that will plot a line at the pre market high or low, but I haven't seen anything that will include after hours prices to determine the high/low point, for example if an equity went lower than both the close and the premarket, then it would be at that after hours low where the line was plotted. Basically what I'm trying to find/create is a standalone study that plots the overnight high and overnight low, taking into account both yesterday's after hours and today's premarket. Please pardon the clunky description, I hope that makes sense!
@krahsloop
Your post was in the wrong thread. I moved it here.
Here there are 11 pages of pre-market and after-hours scripts, plug & play and see if you can modify one for your needs.
 
Last edited:
@Esminiguu Did you try the code in post #3? If that doesn't work then use the code below:

Code:
# TS_GlobexRange
# http://thinkscripter.wordpress.com
# [email protected]
# Last Update 18 JUL 2009

input Globex_Open = 1630;
input Globex_Close = 0930;

def globexOpen = if(secondsFromTime(Globex_Open) >= 0 or secondsTillTime(Globex_Close)>=0, 1, 0);
def globexReset = if globexOpen and !globexOpen[1] then 1 else 0;

rec globexHigh = compoundValue(1, if((high > globexHigh[1] and globexOpen) or globexReset, high,globexHigh[1]),high);
rec globexLow = compoundValue(1, if((low < globexLow[1] and globexOpen) or globexReset, low,globexLow[1]),low);

plot Globex_High = globexHigh;
Globex_high.SetStyle(curve.SHORT_DASH);
Globex_High.SetDefaultColor(color.pink);
Globex_High.setLineWeight(2);
plot Globex_Low = globexLow;
Globex_Low.SetDefaultColor(color.pink);
Globex_Low.setLineWeight(2);
hi, I am using this code, and I think that for US stocks, the Globex_Open = 1600, and Globex_Close = 0929, so the high value is not the first 1 m candle high, if it is higher than the ah/pm high. Also, can you help me to put a column on a WL, for those globex low and high, and how to create values like % from globex low or high, etc? thanks a lot. I used another example, copying some code, do I have to copy this code for each column to get high and low values in different columns? thanks
 
@RandyR Here is code for entire Globex

Code:
# Globex, RTH and prior RTH High and Low
# Request for JQ 11.8.18
# v0.02 11.12.18 will plot prior RTH during current RTH
# Nube

    # inputs
input bubbles = yes;

    # univerals
def na = Double.NaN;
def bn = BarNumber();
def h  = high;
def l  = low;

Script prior {
# subscript for getting prior value of a BarNumber() defined variable
    input prior = close;
    def   priorOf = if prior != prior[1] then prior[1] else priorOf[1];
    plot  priorBar = priorOf;
}
 
   # variables
def cb   = HighestAll(if !IsNaN(h) then bn else na);
def time = GetTime();
def rts  = RegularTradingStart(GetYYYYMMDD());
def rte  = RegularTradingEnd(GetYYYYMMDD());

def RTH = if   time crosses above rts
          then bn else RTH[1];
def globex = if   time crosses below rte
             then bn else globex[1];
# If you want to include the extended session in Globex, then use globex def below
#def globex = if   time crosses above rte
 #            then bn else globex[1];

def priorRTH    = prior(RTH);
def priorGlobex = prior(globex);
def hRTH  = HighestAll(RTH);
def hGX   = HighestAll(globex);
def hPRTH = HighestAll(priorRTH);
def hPGX  = HighestAll(priorGlobex);

def gXhigh = HighestAll(if   bn >= hGX && bn < hRTH
                        then h else if hRTH < hGX && bn >= hGX
                                    then h else na);
def gXlow = LowestAll(if   bn >= hGX && bn < hRTH
                      then l else if hRTH < hGX && bn >= hGX
                                  then l else na);
def RTHhigh = HighestAll(if   bn >= hRTH && bn < hGX
                         then h else if hGX < hRTH && bn >= hRTH
                                    then h else na);
def RTHlow = LowestAll(if   bn >= hRTH && bn < hGX
                       then l else if hGX < hRTH && bn >= hRTH
                                   then l else na);

def priorRTHhigh = HighestAll(if   bn >= hPRTH
                              &&   bn <  if   hGX < hRTH
                                         then hGX
                                         else hPGX
                              then h else na);
def priorRTHlow = LowestAll(if   bn >= hPRTH
                            &&   bn <  if   hGX < hRTH
                                       then hGX
                                       else hPGX
                            then l else na);
                                 
plot
GlobexHigh = gXhigh;
GlobexHigh.SetDefaultColor(Color.Light_Green);
plot
GlobexLow = gXlow;
GlobexLow.SetDefaultColor(Color.Pink);

plot
HighRTH = RTHhigh;
HighRTH.SetDefaultColor(Color.Green);
plot
LowRTH  = RTHlow;
LowRTH.SetDefaultColor(Color.Red);

plot
PreviousHighRTH = priorRTHhigh;
PreviousHighRTH.SetDefaultColor(Color.Dark_Green);
plot
PreviousLowRTH  = priorRTHlow;
PreviousLowRTH.SetDefaultColor(Color.Dark_Red);

AddChartBubble(bubbles && bn == cb, gXhigh, "Globex High", Color.Light_Green);
AddChartBubble(bubbles && bn == cb, RTHhigh, "RTH High", Color.Green);
AddChartBubble(bubbles && bn == cb, priorRTHhigh, "Previous\n RTH High", Color.Dark_Green);
AddChartBubble(bubbles && bn == cb, gXlow, "Globex Low", Color.Pink,0);
AddChartBubble(bubbles && bn == cb, RTHlow, "RTH Low", Color.Red,0);
AddChartBubble(bubbles && bn == cb, priorRTHlow, "Previous\n RTH Low", Color.Dark_Red,0);
# f/ Globex, RTH and prior RTH High and Low

Hi, this doesn't show last night's afterhours low for me, but only shows the premarket low (please see screenshot below). Could it be something in my settings? I can't seem to get any of the overnight studies out there to include yesterday's aftermarket hours, they all seem to calculate from today's premarket only.

cW6DMQ8.jpg
 
Hi, this doesn't show last night's afterhours low for me, but only shows the premarket low (please see screenshot below). Could it be something in my settings? I can't seem to get any of the overnight studies out there to include yesterday's aftermarket hours, they all seem to calculate from today's premarket only.

cW6DMQ8.jpg
have you tried this code?


# TS_GlobexRange
# http://thinkscripter.wordpress.com
# [email protected]
# Last Update 18 JUL 2009

input Globex_Open = 1630;
input Globex_Close = 0930;

def globexOpen = if(secondsFromTime(Globex_Open) >= 0 or secondsTillTime(Globex_Close)>=0, 1, 0);
def globexReset = if globexOpen and !globexOpen[1] then 1 else 0;

rec globexHigh = compoundValue(1, if((high > globexHigh[1] and globexOpen) or globexReset, high,globexHigh[1]),high);
rec globexLow = compoundValue(1, if((low < globexLow[1] and globexOpen) or globexReset, low,globexLow[1]),low);

plot Globex_High = globexHigh;
Globex_high.SetStyle(curve.SHORT_DASH);
Globex_High.SetDefaultColor(color.pink);
Globex_High.setLineWeight(2);
plot Globex_Low = globexLow;
Globex_Low.SetDefaultColor(color.pink);
Globex_Low.setLineWeight(2);
 
have you tried this code?


# TS_GlobexRange
# http://thinkscripter.wordpress.com
# [email protected]
# Last Update 18 JUL 2009

input Globex_Open = 1630;
input Globex_Close = 0930;

def globexOpen = if(secondsFromTime(Globex_Open) >= 0 or secondsTillTime(Globex_Close)>=0, 1, 0);
def globexReset = if globexOpen and !globexOpen[1] then 1 else 0;

rec globexHigh = compoundValue(1, if((high > globexHigh[1] and globexOpen) or globexReset, high,globexHigh[1]),high);
rec globexLow = compoundValue(1, if((low < globexLow[1] and globexOpen) or globexReset, low,globexLow[1]),low);

plot Globex_High = globexHigh;
Globex_high.SetStyle(curve.SHORT_DASH);
Globex_High.SetDefaultColor(color.pink);
Globex_High.setLineWeight(2);
plot Globex_Low = globexLow;
Globex_Low.SetDefaultColor(color.pink);
Globex_Low.setLineWeight(2);

Very neat script that follows the high and low, thank you!
 
Here is an update to track prev values like that @autolox asked for.

Vd6HQ0R.png


Code:
#
# see https://usethinkscript.com/threads/how-to-get-current-days-premarket-high.695/
#
declare once_per_bar;

input PlotPreMktLinesHrsPastOpen = yes;
input ShowChartBubbles = yes;

def bar = BarNumber();
def nan = Double.NaN;
def vHigh = high;
def vLow = low;

def PMhrs = RegularTradingStart (GetYYYYMMDD()) > GetTime();
def RMhrs = RegularTradingStart (GetYYYYMMDD()) < GetTime();
def PMStart = RMhrs[1] and PMhrs;
def PMHigh = CompoundValue(1, if PMStart then vHigh else if PMhrs then Max(vHigh, PMHigh[1]) else PMHigh[1], nan);
def PMLow = CompoundValue(1, if PMStart then vLow else if PMhrs then Min(vLow, PMLow[1]) else PMLow[1], nan);
def highBar = if PMhrs and vHigh == PMHigh then bar else nan;
def lowBar = if PMhrs and vLow == PMLow then bar else nan;
def PMHighBar = if bar == HighestAll(highBar) then PMHigh else PMHighBar[1];
def PMLowBar = if bar == HighestAll(lowBar) then PMLow else PMLowBar[1];

plot PMH =  if PlotPreMktLinesHrsPastOpen and PMHighBar != 0
            then PMHighBar
            else nan;
plot PML =  if PlotPreMktLinesHrsPastOpen and PMLowBar != 0
            then PMLowBar
            else nan;
plot PMMid = if PlotPreMktLinesHrsPastOpen and PMHighBar != 0 and PMLowBar != 0
             then (PMHighBar + PMLowBar) / 2
             else nan;


def prevPMHigh = if PMStart[-1] then PMHigh[1] else prevPMHigh[1];
plot pPMH = if !IsNaN(prevPMHigh) and prevPMHigh != 0 then prevPMHigh else nan;
pPMH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
pPMH.AssignValueColor(PMH.TakeValueColor());

def prevPMLow = if PMStart[-1] then PMLow[1] else prevPMLow[1];
plot pPML = if !IsNaN(prevPMLow) and prevPMLow != 0 then prevPMLow else nan;
pPML.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
pPML.AssignValueColor(PML.TakeValueColor());

def prevPMMid = if PMStart[-1] then ((PMHigh[1]+PMLow[1])/2) else prevPMMid[1];
plot pPMM = if !IsNaN(prevPMMid) and prevPMMid != 0 then prevPMMid else nan;
pPMM.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
pPMM.AssignValueColor(PMMid.TakeValueColor());


AddChartBubble(ShowChartBubbles and bar == HighestAll(highBar),
  PMHigh,
  "PM High",
  Color.GRAY,
  1);

AddChartBubble(ShowChartBubbles and bar == HighestAll(lowBar),
  PMLow,
  "PM Low",
  Color.GRAY,
  0);

AddChartBubble(ShowChartBubbles and bar == Max(HighestAll(highBar), HighestAll(lowBar)),
  (PMHighBar + PMLowBar) / 2,
  "PM Mid",
  Color.GRAY,
  1);

# end of script

@korygill Newbie here, Great Code. I will be using this for Yesterday's Pre market H/L lines on today's chart. Is there a way you can change the code to show just the After Market Close (post market hours High/Low) Lines from 2 days ago instead of Pre Market High/Low lines from Yesterday. Basically the same concept as above except for it to plot After Market (evening hours H/L lines from 2 days ago) instead of Pre market (from 1 day ago) on Today's chart.

Greatly appreciate your help.

Also if possible, is there a way to have a new code/script to Auto Draw Pre market High/ Low lines and a separate script to Auto Draw After Market High/Low lines based on user input of how many days ago. This way I can put mulitple of same studies on chart and lets say pick 1 day ago or 2 days ago or 3 days ago etc etc Pre Market High/Low lines and After market High Low Lines Auto drawn on just today's 1M1D chart.

Thank you
 
Can anyone make a script that shows Pre Market Low/High as an Upper Label?
Pre Market high label

Code:
def h = high;
def bar = BarNumber();
def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());

def ONhigh = if GlobeX and !GlobeX[1] then h else if GlobeX and h > ONhigh[1] then h else ONhigh[1];
def ONhighBar = if GlobeX and h == ONhigh then bar else Double.NaN;
def OverNightHigh = if BarNumber() == HighestAll(ONhighBar) then ONhigh else OverNightHigh[1];
AddLabel(1, "PM High: " + Round(OverNightHigh,2), createcolor(204,204,255));
 
Pre Market high label

Code:
def h = high;
def bar = BarNumber();
def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());

def ONhigh = if GlobeX and !GlobeX[1] then h else if GlobeX and h > ONhigh[1] then h else ONhigh[1];
def ONhighBar = if GlobeX and h == ONhigh then bar else Double.NaN;
def OverNightHigh = if BarNumber() == HighestAll(ONhighBar) then ONhigh else OverNightHigh[1];
AddLabel(1, "PM High: " + Round(OverNightHigh,2), createcolor(204,204,255));
@zeek, Can you please do the same label code for a pre market High / Low from 1 day ago, from 2 days ago, from 3 days ago, 4 days ago and 5 days ago? And the same for after market high/low from 1, 2, 3, 4 & 5 days ago?

Thank you so much
 
@zeek, Can you please do the same label code for a pre market High / Low from 1 day ago, from 2 days ago, from 3 days ago, 4 days ago and 5 days ago? And the same for after market high/low from 1, 2, 3, 4 & 5 days ago?

Thank you so much

This seems to work with stocks for after/premarket period's highs/lows. For other instruments that trade overnight, such as /ES, the premarket is more representative for the highs/lows.

Capture.jpg
Ruby:
#Labels for After/Pre Market Highe/Lows for today and 5 prior days
#
script aft {
    input daysback = 1;
    def ymd      = GetYYYYMMDD();
    def capture  = !IsNaN(close) and ymd != ymd[1];
    def dayCount = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0);
    def thisDay  = HighestAll(dayCount) - dayCount  ;

    def ahigh    = if thisDay[1] == daysback + 1 and gettime() crosses above regularTradingEnd(getyyyYMMDD())
                   then high
                   else if thisDay[1] == daysback + 1 and thisDay >= daysback + 1
                   then  Max(high, ahigh[1]) else ahigh[1];
    def alow    = if thisDay[1] == daysback + 1 and gettime() crosses above regularTradingEnd(getyyyYMMDD())
                  then low
                  else if thisDay[1] == daysback + 1 and thisDay >= daysback + 1
                  then  Min(low, alow[1]) else alow[1];
    plot ah     = ahigh;
    plot al     = alow;
}
AddLabel(1, "AFT: H5: " + asdollars(aft(5)) + " H4: " + asdollars(aft(4)) + " H3: " + asdollars(aft(3)) + " H2: " + asdollars(aft(2)) + " H1: " + asdollars(aft(1)) + " H: " + asdollars(aft(0)), Color.LIGHT_GREEN);
AddLabel(1, " L5: " + asdollars(aft(5).al) + " L4: " + asdollars(aft(4).al) + " L3: " + asdollars(aft(3).al) + " H2: " + asdollars(aft(2).al) + " L1: " + asdollars(aft(1).al) + " L: " + asdollars(aft(0).al), Color.PINK);


script pre {
    input daysback = 1;
    def ymd      = GetYYYYMMDD();
    def capture  = !IsNaN(close) and ymd != ymd[1];
    def dayCount = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0);
    def thisDay  = HighestAll(dayCount) - dayCount  ;

    def phigh    = if thisDay[1] == daysback + 1 and thisDay == daysback
                   then high
                   else if thisDay == daysback and GetTime() < RegularTradingStart(GetYYYYMMDD())
                   then  Max(high, phigh[1]) else phigh[1];
    def plow    = if thisDay[1] == daysback + 1 and thisDay == daysback
                  then low
                  else if thisDay == daysback and GetTime() < RegularTradingStart(GetYYYYMMDD())
                  then  Min(low, plow[1]) else plow[1];
    plot ph     = phigh;
    plot pl     = plow;
}
AddLabel(1, "PRE: H5: " + asdollars(pre(5)) + " H4: " + asdollars(pre(4)) + " H3: " + asdollars(pre(3)) + " H2: " + asdollars(pre(2)) + " H1: " + asdollars(pre(1)) + " H: " + asdollars(pre(0)), Color.LIGHT_GREEN);
AddLabel(1, " L5: " + asdollars(pre(5).pl) + " L4: " + asdollars(pre(4).pl) + " L3: " + asdollars(pre(3).pl) + " H2: " + asdollars(pre(2).pl) + " L1: " + asdollars(pre(1).pl) + " L: " + asdollars(pre(0).pl), Color.PINK);
#
 
Here is an update to track prev values like that @autolox asked for.

Vd6HQ0R.png


Code:
#
# see https://usethinkscript.com/threads/how-to-get-current-days-premarket-high.695/
#
declare once_per_bar;

input PlotPreMktLinesHrsPastOpen = yes;
input ShowChartBubbles = yes;

def bar = BarNumber();
def nan = Double.NaN;
def vHigh = high;
def vLow = low;

def PMhrs = RegularTradingStart (GetYYYYMMDD()) > GetTime();
def RMhrs = RegularTradingStart (GetYYYYMMDD()) < GetTime();
def PMStart = RMhrs[1] and PMhrs;
def PMHigh = CompoundValue(1, if PMStart then vHigh else if PMhrs then Max(vHigh, PMHigh[1]) else PMHigh[1], nan);
def PMLow = CompoundValue(1, if PMStart then vLow else if PMhrs then Min(vLow, PMLow[1]) else PMLow[1], nan);
def highBar = if PMhrs and vHigh == PMHigh then bar else nan;
def lowBar = if PMhrs and vLow == PMLow then bar else nan;
def PMHighBar = if bar == HighestAll(highBar) then PMHigh else PMHighBar[1];
def PMLowBar = if bar == HighestAll(lowBar) then PMLow else PMLowBar[1];

plot PMH =  if PlotPreMktLinesHrsPastOpen and PMHighBar != 0
            then PMHighBar
            else nan;
plot PML =  if PlotPreMktLinesHrsPastOpen and PMLowBar != 0
            then PMLowBar
            else nan;
plot PMMid = if PlotPreMktLinesHrsPastOpen and PMHighBar != 0 and PMLowBar != 0
             then (PMHighBar + PMLowBar) / 2
             else nan;


def prevPMHigh = if PMStart[-1] then PMHigh[1] else prevPMHigh[1];
plot pPMH = if !IsNaN(prevPMHigh) and prevPMHigh != 0 then prevPMHigh else nan;
pPMH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
pPMH.AssignValueColor(PMH.TakeValueColor());

def prevPMLow = if PMStart[-1] then PMLow[1] else prevPMLow[1];
plot pPML = if !IsNaN(prevPMLow) and prevPMLow != 0 then prevPMLow else nan;
pPML.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
pPML.AssignValueColor(PML.TakeValueColor());

def prevPMMid = if PMStart[-1] then ((PMHigh[1]+PMLow[1])/2) else prevPMMid[1];
plot pPMM = if !IsNaN(prevPMMid) and prevPMMid != 0 then prevPMMid else nan;
pPMM.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
pPMM.AssignValueColor(PMMid.TakeValueColor());


AddChartBubble(ShowChartBubbles and bar == HighestAll(highBar),
  PMHigh,
  "PM High",
  Color.GRAY,
  1);

AddChartBubble(ShowChartBubbles and bar == HighestAll(lowBar),
  PMLow,
  "PM Low",
  Color.GRAY,
  0);

AddChartBubble(ShowChartBubbles and bar == Max(HighestAll(highBar), HighestAll(lowBar)),
  (PMHighBar + PMLowBar) / 2,
  "PM Mid",
  Color.GRAY,
  1);

# end of script

how do you move the bubbles and labels to the right side?
 
Trying to get a SCANNER to work with OP's high low.

Regular trading hours alert even with the check box turned off
Def Active = GetTime() >= RegularTradingStart(getYYYYMMDD()) and GetTime() <= RegularTradingEnd(getYYYYMMDD());

Get it to work with
close is greater than or equal to PHL()."ONH"

Appreciate any help.
 
I'm looking for a premarket high label that's green if price is over and red if price is under. Same for premarket low but I want them separate. I've been able to do it for open price, yday high, yday low, and yday close but I can't figure it out for premarket. Or really I want it for all extended trading hours.
 
I'm looking for a premarket high label that's green if price is over and red if price is under. Same for premarket low but I want them separate. I've been able to do it for open price, yday high, yday low, and yday close but I can't figure it out for premarket. Or really I want it for all extended trading hours.
Here are the top 40 posts in this thread that discusses premarket labels.
See what comes close, and then come back with any specific questions:
https://usethinkscript.com/search/779673/?q=label&t=post&c[thread]=75&o=date
 
@RandyR Here is code for entire Globex

Code:
# Globex, RTH and prior RTH High and Low
# Request for JQ 11.8.18
# v0.02 11.12.18 will plot prior RTH during current RTH
# Nube

    # inputs
input bubbles = yes;

    # univerals
def na = Double.NaN;
def bn = BarNumber();
def h  = high;
def l  = low;

Script prior {
# subscript for getting prior value of a BarNumber() defined variable
    input prior = close;
    def   priorOf = if prior != prior[1] then prior[1] else priorOf[1];
    plot  priorBar = priorOf;
}
 
   # variables
def cb   = HighestAll(if !IsNaN(h) then bn else na);
def time = GetTime();
def rts  = RegularTradingStart(GetYYYYMMDD());
def rte  = RegularTradingEnd(GetYYYYMMDD());

def RTH = if   time crosses above rts
          then bn else RTH[1];
def globex = if   time crosses below rte
             then bn else globex[1];
# If you want to include the extended session in Globex, then use globex def below
#def globex = if   time crosses above rte
 #            then bn else globex[1];

def priorRTH    = prior(RTH);
def priorGlobex = prior(globex);
def hRTH  = HighestAll(RTH);
def hGX   = HighestAll(globex);
def hPRTH = HighestAll(priorRTH);
def hPGX  = HighestAll(priorGlobex);

def gXhigh = HighestAll(if   bn >= hGX && bn < hRTH
                        then h else if hRTH < hGX && bn >= hGX
                                    then h else na);
def gXlow = LowestAll(if   bn >= hGX && bn < hRTH
                      then l else if hRTH < hGX && bn >= hGX
                                  then l else na);
def RTHhigh = HighestAll(if   bn >= hRTH && bn < hGX
                         then h else if hGX < hRTH && bn >= hRTH
                                    then h else na);
def RTHlow = LowestAll(if   bn >= hRTH && bn < hGX
                       then l else if hGX < hRTH && bn >= hRTH
                                   then l else na);

def priorRTHhigh = HighestAll(if   bn >= hPRTH
                              &&   bn <  if   hGX < hRTH
                                         then hGX
                                         else hPGX
                              then h else na);
def priorRTHlow = LowestAll(if   bn >= hPRTH
                            &&   bn <  if   hGX < hRTH
                                       then hGX
                                       else hPGX
                            then l else na);
                                 
plot
GlobexHigh = gXhigh;
GlobexHigh.SetDefaultColor(Color.Light_Green);
plot
GlobexLow = gXlow;
GlobexLow.SetDefaultColor(Color.Pink);

plot
HighRTH = RTHhigh;
HighRTH.SetDefaultColor(Color.Green);
plot
LowRTH  = RTHlow;
LowRTH.SetDefaultColor(Color.Red);

plot
PreviousHighRTH = priorRTHhigh;
PreviousHighRTH.SetDefaultColor(Color.Dark_Green);
plot
PreviousLowRTH  = priorRTHlow;
PreviousLowRTH.SetDefaultColor(Color.Dark_Red);

AddChartBubble(bubbles && bn == cb, gXhigh, "Globex High", Color.Light_Green);
AddChartBubble(bubbles && bn == cb, RTHhigh, "RTH High", Color.Green);
AddChartBubble(bubbles && bn == cb, priorRTHhigh, "Previous\n RTH High", Color.Dark_Green);
AddChartBubble(bubbles && bn == cb, gXlow, "Globex Low", Color.Pink,0);
AddChartBubble(bubbles && bn == cb, RTHlow, "RTH Low", Color.Red,0);
AddChartBubble(bubbles && bn == cb, priorRTHlow, "Previous\n RTH Low", Color.Dark_Red,0);
# f/ Globex, RTH and prior RTH High and Low
Hi Ben,

Are you able to add a mid line between the GlobexHigh and GlobexLow?
 
This indicator for ThinkorSwim will automatically plot overnight High and Low on your chart. In addition, the indicator will also include Fibonacci retracement based on the highest and lowest values from pre-market.

This can be useful for anyone who often plays pre-market breakout or breakdown. You may want to check out this strategy as well.

uUiRGl0.png


thinkScript Code

Rich (BB code):
# GlobeX or Overnight High / Low with Fibonacci Values 

# Mobius 

# V01.2012 

input PlotOverNightExtremes = yes;

input coeff_1 = .236;

input coeff_2 = .327;

# gmh: added the rest of the Fibs 

input coeff_3 = .500;

input coeff_4 = .618;

input coeff_5 = .789;

input coeff_6 = .882;



def o = open;

def h = high;

def l = low;

def c = close;

def v = volume;

def bar = BarNumber();

def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());

def vol = if GlobeX and !Globex[1]

          then v

          else if GlobeX

               then vol[1] + v

               else Double.NaN;

def GlobeX_Volume = vol;

def ONhigh = if GlobeX and !Globex[1]

             then h

             else if Globex and

                     h > ONhigh[1]

                     then h

                  else ONhigh[1];

def ONhighBar = if GlobeX and h == ONhigh

                then Bar

                else double.nan;

def ONlow = if GlobeX and !GlobeX[1]

            then l

            else if GlobeX and

                    l < ONlow[1]

            then l

                 else ONlow[1];

def ONlowBar = if GlobeX and l == ONlow

               then Bar

               else double.nan;

def OverNightHigh = if BarNumber() == HighestAll(ONhighBar)

                    then ONhigh

                    else OverNightHigh[1];

def OverNightLow = if BarNumber() == HighestAll(ONlowBar)

                   then ONlow

                   else OverNightLow[1];

plot ONH = if OverNightHigh > 0

           then OverNightHigh

           else Double.NaN;

     ONH.SetHiding(!PlotOverNightExtremes);

     ONH.SetPaintingStrategy(PaintingStrategy.SQUARES);

     ONH.SetDefaultColor(Color.BLUE);

     ONH.HideBubble();

     ONH.HideTitle();

plot ONL = if OverNightLow > 0

           then OverNightLow

           else Double.NaN;

     ONL.SetHiding(!PlotOverNightExtremes);

     ONL.SetPaintingStrategy(PaintingStrategy.SQUARES);

     ONL.SetDefaultColor(Color.LIGHT_GRAY);

     ONL.HideBubble();

     ONL.HideTitle();



def MaxBar = Max(HighestAll(ONhighBar), HighestAll(ONlowBar));



plot coeff1 = if HighestAll(ONhighBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then ((OverNightHigh - OverNightLow) * coeff_1) + OverNightLow

              else if HighestAll(ONlowBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then OverNightHigh - ((OverNightHigh - OverNightLow) * coeff_1)

              else double.nan;

plot coeff2 = if HighestAll(ONhighBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then ((OverNightHigh - OverNightLow) * coeff_2) + OverNightLow

               else if HighestAll(ONlowBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then OverNightHigh - ((OverNightHigh - OverNightLow) * coeff_2)

              else double.nan;

plot coeff3 = if HighestAll(ONhighBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then ((OverNightHigh - OverNightLow) * coeff_3) + OverNightLow

              else if HighestAll(ONlowBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then OverNightHigh - ((OverNightHigh - OverNightLow) * coeff_3)

              else double.nan;

plot coeff4 = if HighestAll(ONhighBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then ((OverNightHigh - OverNightLow) * coeff_4) + OverNightLow

              else if HighestAll(ONlowBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then OverNightHigh - ((OverNightHigh - OverNightLow) * coeff_4)

              else double.nan;

plot coeff5 = if HighestAll(ONhighBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then ((OverNightHigh - OverNightLow) * coeff_5) + OverNightLow

              else if HighestAll(ONlowBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then OverNightHigh - ((OverNightHigh - OverNightLow) * coeff_5)

              else double.nan;

plot coeff6 = if HighestAll(ONhighBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then ((OverNightHigh - OverNightLow) * coeff_6) + OverNightLow

              else if HighestAll(ONlowBar) == MaxBar and OverNightLow > 0 and OverNightHigh > 0

              then OverNightHigh - ((OverNightHigh - OverNightLow) * coeff_6)

              else double.nan;

# 

# End Code GlobeX High Low with Fibs 

Shareable Link

https://tos.mx/oNY5Yw
Hi, has this or can this can be updated to reference the Previous Day Close as the Low?
Many thanks
 
Hi, has this or can this can be updated to reference the Previous Day Close as the Low?
Many thanks
It is not clear what you are asking for.
Sounds like something you may have to post a picture of to explain what you are trying to accomplish along with a more detailed explanation.
Unsure of how to upload screenshots to the forum, Here are directions.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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