How do you get the Time of High of Day?

ankbhard

New member
I am trying to build a script with labels that will show at what "Time" the HOD and LOD occurred on an intraday chart. Like in the attached picture...

Example: The HOD was put in at 11:46 am and LOD was put in at 9:30 am. Another label to show the difference between LOD to HOD.

Any suggestions and feedback are greatly appreciated.
 
Last edited by a moderator:
I hope this is what you are requesting on the above request
Code:
#Bubbles showing based upon a 'cond'

input showBubbles_Limited_by_Count = yes;
input updown_bubblemover   = 3; # number of ticks * ticksize()
input sideways_bubblemover = 3; # shifts bubble right (pos) / left (neg)
def b = -sideways_bubblemover;
def b1 = b + 1;

def cond = if Volume ==  HighestAll(volume) then 1 else Double.NaN;

#Bubbles to be displayed are limited by the number input at 'bubble_limit', excluding the last bubble, which follows in code below. The last bubble was separated to show how to connect the offset bubble_limit to the bar it is referencing

input bubble_limit = 3;
def dataCount  = if !IsNaN(cond) == 1    then  dataCount[1] + 1  else dataCount[1];
def dataCountb = if !IsNaN(cond[b]) == 1 then  dataCountb[1] + 1 else dataCountb[1];


#Example of Drawing a Line between the last offset bubble and the bar it is referencing

input show_Last_Bubble_Limited_by_Count = yes;

AddChartBubble(show_Last_Bubble_Limited_by_Count and HighestAll(dataCount) - dataCount <= bubble_limit - 1 and   !IsNaN(cond[b1]) == 0 and !IsNaN(cond[b]) == 1,
    high[b] + TickSize() * updown_bubblemover,
    "$" +
    hl2[b1] , Color.gray, yes);

plot hh  = if HighestAll(dataCount) - dataCount <= bubble_limit - 1 and !IsNaN(cond) == 1
           then hl2
           else Double.NaN;
plot hh1 = if HighestAll(dataCountb) - dataCountb <= bubble_limit - 1 and !IsNaN(cond[b]) == 1
           then high[b] + TickSize() * updown_bubblemover
           else Double.NaN;
plot hhline = if !IsNaN(cond[b]) == 1 then hh1 else if !IsNaN(cond) == 1 then hh else Double.NaN;
hhline.SetDefaultColor( Color.WHITE);
hhline.EnableApproximation();
hhline.SetLineWeight(3);

Here is the code modified to do a lower indicator with rsi used in the condition. I eliminated the line drawing from the offset bubble, because it only works best as in the first volume code above, with just one bubble.
Code:
declare lower;

plot rsi = rsi();

plot oversold = RSI().OverSold;

#Bubbles showing based upon a 'cond'



input showBubbles_Limited_by_Count = yes;

input updown_bubblemover   = -5; # number of ticks * ticksize()

input sideways_bubblemover = -4; # shifts bubble right (pos) / left (neg)

def b = -sideways_bubblemover;

def b1 = b + 1;



def cond = if rsi() crosses above RSI().Oversold then 1 else Double.NaN;



#Bubbles to be displayed are limited by the number input at 'bubble_limit', excluding the last bubble, which follows in code below. The last bubble was separated to show how to connect the offset bubble_limit to the bar it is referencing



input bubble_limit = 3;

def dataCount  = if !IsNaN(cond) == 1    then  dataCount[1] + 1  else dataCount[1];

def dataCountb = if !IsNaN(cond[b]) == 1 then  dataCountb[1] + 1 else dataCountb[1];





#Example of Drawing a Line between the last offset bubble and the bar it is referencing



input show_Last_Bubble_Limited_by_Count = yes;



AddChartBubble(show_Last_Bubble_Limited_by_Count and HighestAll(dataCount) - dataCount <= bubble_limit - 1 and   !IsNaN(cond[b1]) == 0 and !IsNaN(cond[b]) == 1,

    RSI().OverSold[b] +  updown_bubblemover,

    "" +     RSI()[b1] , Color.gray, no);



plot hh  = if HighestAll(dataCount) - dataCount <= bubble_limit - 1 and !IsNaN(cond) == 1

           then RSI()

           else Double.NaN;

plot hh1 = if HighestAll(dataCountb) - dataCountb <= bubble_limit - 1 and !IsNaN(cond[b]) == 1

           then rsi()[b] + TickSize() * updown_bubblemover

           else Double.NaN;

#plot hhline = if !IsNaN(cond[b]) == 1 then hh1 else if !IsNaN(cond) == 1 then hh else Double.NaN;

#hhline.SetDefaultColor( Color.WHITE);

#hhline.EnableApproximation();

#hhline.SetLineWeight(3);
 
Last edited:

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

Example of Plotting Hour:Min Time Stamp at Regular Trading Hours High of Day ( RTH HOD )
By: The one and only Legendary .... Mobius!
Request 01.19.2021
(Zero fix and hours offset by XeoNoX)
Change Hours Offset in the input to HRS you need to adjust for daylight savings or your local timezone


REMEMBER TO THUMBS UP IF YOU FOUND THIS POST USEFUL

NHuvBLW.jpg



Code:
# Example of Plotting Hour:Min Time Stamp at Regular Trading Hours High of Day  ( RTH HOD )
#By Mobius
# Request 01.19.2021
#(Zero fix and hours offset by XeoNoX)
#Change Hours_Offset in the input to HRS you need to adjust for daylight savings or your local timezone
input Hours_Offset = 0;
input Start = 9.5;
input End = 1600;

def h = high;
def c = close;
def x = BarNumber();
def D = 86400;
def Hr = 3600;
def epoch = (GetTime() / 1000);
def hour = ((epoch % D) / Hr); # 5 hour diff for GMT
def roll = if hour > 5
           then hour - 5
           else if hour < 5
           then (hour + 24) - 5
           else 0;
def min = Floor(((epoch % D) % Hr)) / 60;
def RTH_HOD = if roll crosses above Start
              then h
              else if Between(roll, Start, End)
              then Max(h, RTH_HOD[1])
              else RTH_HOD[1];
def HODx;
def HODHr;
def HODmin;
if RTH_HOD == h
{
    HODx = x;
    HODHr = roll;
    HODmin = min;
}
else
{
    HODx = HODx[1];
    HODHr = HODHr[1];
    HODmin = HODmin[1];
}



AddChartBubble(x == HighestAll(HODx), RTH_HOD, if HODmin > 9 then "HOD " +  (RTH_HOD) + "  @" + Floor(HODHr + Hours_Offset) + ":" + HODmin + "AM"  else "Highest Volume Today " +  (RTH_HOD) + "  @" + Floor(HODHr + Hours_Offset) + ":0" + HODmin + "AM" , Color.CYAN);
AddVerticalLine(roll crosses above Start);


AddLabel (yes, if HODmin > 9 then "HOD " +  (RTH_HOD) + "  @" + Floor(HODHr + Hours_Offset) + ":" + HODmin + "AM"  else "Highest Volume Today " +  (RTH_HOD) + "  @" + Floor(HODHr + Hours_Offset) + ":0" + HODmin + "AM"   );
# End Code

Greetings. Firstly, I appreciate everyone's contribution to this site. It's amazing.

I was looking to see if someone already asked and I haven't found anything yet.

Is there a LOD of this script already created? I managed to fit this HOD script into one of my watchlist columns and it makes it incredibly clear when the market is reversing after seeing multiple stocks reach their HOD at the same time through my watchlist. If there is a LOD script for this, I would widely appreciate it if someone could point me in the right direction. The time factor/script in my watchlist column helps tremendously.
 
Greetings. Firstly, I appreciate everyone's contribution to this site. It's amazing.

I was looking to see if someone already asked and I haven't found anything yet.

Is there a LOD of this script already created? I managed to fit this HOD script into one of my watchlist columns and it makes it incredibly clear when the market is reversing after seeing multiple stocks reach their HOD at the same time through my watchlist. If there is a LOD script for this, I would widely appreciate it if someone could point me in the right direction. The time factor/script in my watchlist column helps tremendously.
hello and welcome
that strategy sounds interesting , multiple HOD in a column.

i'm busy now , but tonight i will work on a ver that can do both ( unless someone beats me to it).
 
Greetings. Firstly, I appreciate everyone's contribution to this site. It's amazing.

I was looking to see if someone already asked and I haven't found anything yet.

Is there a LOD of this script already created? I managed to fit this HOD script into one of my watchlist columns and it makes it incredibly clear when the market is reversing after seeing multiple stocks reach their HOD at the same time through my watchlist. If there is a LOD script for this, I would widely appreciate it if someone could point me in the right direction. The time factor/script in my watchlist column helps tremendously.

See if this adaption of a watchlist RTH Highs/Lows that I previously did works for you. It will only plot the last days RTH Highs/Lows

Capture.jpg
Ruby:
#Watchlist Column - High of Day and Time Occurred
#20210529 Sleepyz = UseThinkscript Request
#Adapted Watchlist to display labels/bubbles for last RTH Highs/Lows

input showlabel           = yes;
input showbubbles         = yes;
input showprice_in_bubble = yes;
#Time Defined
input timezone = {default "ET", "CT", "MT",  "PT"};

def starthour  = (if timezone == timezone."ET"
                        then 9
                        else if timezone == timezone."CT"
                        then 8
                        else if timezone == timezone."MT"
                        then 7
                        else 6) ;
def hour = Floor(((starthour * 60 + 30) + (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000) / 60);
def minutes = (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000 - ((hour - starthour) * 60 + 30) + 60;

#Highest High during RTH
def begin      = CompoundValue(1, if GetTime() crosses above RegularTradingStart(GetYYYYMMDD())
                                       then high
                                       else if high > begin[1]
                                       then high
                                       else begin[1]
                                  , begin[1]);
def beginbn    = if GetDay() == GetLastDay()
                 then if high == begin
                      then BarNumber()
                      else beginbn[1]
                 else 0;
def highday    = if BarNumber() == HighestAll(beginbn)
                 then high
                 else highday[1];
def hihr    = if  high == highday then hour else hihr[1];
def himin   = if  high == highday then minutes else himin[1];

AddLabel(showlabel,
           "H: " +
           (hihr + ":") +
           (if himin < 10
            then "0" + himin
            else  "" + himin) +
            " | " +
            Asdollars(highday), Color.WHITE);

AddChartBubble(showbubbles and high == highday, high,
           "H: "+
           (hihr + ":") +
           (if himin < 10
            then "0" + himin
            else  "" + himin) +
            "\n" +
            if showprice_in_bubble then Asdollars(highday) else "", Color.WHITE);


#Lowest Low During RTH
def begin1 = CompoundValue(1,  if GetTime() crosses above RegularTradingStart(GetYYYYMMDD())
                               then low
                               else if low < begin1[1]
                               then low
                               else begin1[1],
                              low);
def beginbn1    = if GetDay() == GetLastDay()
                  then if low == begin1
                       then BarNumber()
                       else beginbn1[1]
                  else 0;
def lowday     = if BarNumber() == HighestAll(beginbn1)
                 then low
                 else lowday[1];

def lowhr    = if low == lowday then hour else lowhr[1];
def lowmin   = if low == lowday then minutes else lowmin[1];


AddLabel(showlabel,
           "L: " +
           (lowhr + ":") +
           (if lowmin < 10
            then "0" + lowmin
            else  "" + lowmin ) +
            " | " + Asdollars(lowday) , Color.YELLOW);

AddChartBubble(showbubbles and low == lowday, low,
           "L: " +
           (lowhr + ":") +
           (if lowmin < 10
            then "0" + lowmin
            else  "" + lowmin) +
            "\n" +
            if showprice_in_bubble then Asdollars(lowday) else "", Color.yellow, no);
 
Thank you. I will see what I can do. I appreciate it

@Beauteallover were you able to make a column version?
i saw sleepyz posted a chart study, so i waited to see if it worked for you.

i made this watchlist column study version of @SleepyZ study in post25 (thanks for posting it)
'include extended hours' needs to be checked


zhilotime0b
http://tos.mx/N8zQEhO
this version shows the time and the price


since this is a column study, you can't change inputs. you have to change the code.
for 2 variables, there are 2 versions of the code line.
enable one of them and
disable the other one. ( by putting a # in front of the line)


these code lines are near the beginning of the study.

#---------------------------------
# change which line is enabled, to show the price

input showprice_in_bubble = yes;
#input showprice_in_bubble = no;
#---------------------------------

#---------------------------------
# enable 1 of these lines , first for time, 2nd for bars back . notice the placement of 'default'
#
input display = { default time , bars_back };
#input display = { time , default bars_back };
#---------------------------------


color of the font is based on which is the most recent, hod or lod.
if the high price is most recent then the cell is green, if low price is most recent then red.

i put H or L as the first character, for sorting like items together.

it uses 4 labels, and enables 1 at a time, depending on the data.

column study

Ruby:
# zhilotime0b

# mod chart study for a column
# bars back since hi/lo

# https://usethinkscript.com/threads/how-do-you-get-the-time-of-high-of-day.3751/page-2#post-97451
# SleepyZ


#---------------------------------
# change which line is enabled, to show the price

input showprice_in_bubble = yes;
#input showprice_in_bubble = no;
#---------------------------------


#---------------------------------
# enable 1 of these lines , first for time, 2nd for bars back
#
input display = { default time , bars_back };
#input display = { time , default bars_back };
#---------------------------------

def d;
switch (display) {
case time:
 d = 1;
case bars_back:
 d = 2;
}


def bn = barnumber();

#Time Defined
input timezone = {default "ET", "CT", "MT",  "PT"};

def starthour  = (if timezone == timezone."ET"
                        then 9
                        else if timezone == timezone."CT"
                        then 8
                        else if timezone == timezone."MT"
                        then 7
                        else 6) ;
def hour = Floor(((starthour * 60 + 30) + (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000) / 60);
def minutes = (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000 - ((hour - starthour) * 60 + 30) + 60;

#Highest High during RTH
def dayhi      = CompoundValue(1, if GetTime() crosses above RegularTradingStart(GetYYYYMMDD())
                                       then high
                                       else if high > dayhi[1]
                                       then high
                                       else dayhi[1]
                                  , dayhi[1]);
def dayhibn    = if GetDay() == GetLastDay()
                 then if high == dayhi
                      then BarNumber()
                      else dayhibn[1]
                 else 0;
def highday    = if BarNumber() == HighestAll(dayhibn)
                 then high
                 else highday[1];
def hihr    = if  high == highday then hour else hihr[1];
def himin   = if  high == highday then minutes else himin[1];

def hibarsago = bn - dayhibn;

# AddLabel(showlabel,
#           "H: " +
#           (hihr + ":") +
#           (if himin < 10
#            then "0" + himin
#            else  "" + himin) +
#            " | " +
#            Asdollars(highday), Color.WHITE);

#addlabel(1, hibarsago, Color.magenta);

#AddChartBubble(showbubbles and high == highday, high,
#           "H: "+
#           (hihr + ":") +
#           (if himin < 10
#            then "0" + himin
#            else  "" + himin) +
#            "\n" +
#            (if showprice_in_bubble then Asdollars(highday) else ""), Color.WHITE);


#addlabel(1, "  ", Color.black);


#Lowest Low During RTH
def daylo = CompoundValue(1,  if GetTime() crosses above RegularTradingStart(GetYYYYMMDD())
                               then low
                               else if low < daylo[1]
                               then low
                               else daylo[1],
                              low);
def daylobn    = if GetDay() == GetLastDay()
                  then if low == daylo
                       then BarNumber()
                       else daylobn[1]
                  else 0;
def lowday     = if BarNumber() == HighestAll(daylobn)
                 then low
                 else lowday[1];

def lowhr    = if low == lowday then hour else lowhr[1];
def lowmin   = if low == lowday then minutes else lowmin[1];

def lobarsago = bn - daylobn;


#AddLabel(showlabel,
#           "L: " +
#           (lowhr + ":") +
#           (if lowmin < 10
#            then "0" + lowmin
#            else  "" + lowmin ) +
#            " | " + Asdollars(lowday) , Color.YELLOW);

#addlabel(1, lobarsago, Color.magenta);


#AddChartBubble(showbubbles and low == lowday, low,
#           "L: " +
#           (lowhr + ":") +
#           (if lowmin < 10
#            then "0" + lowmin
#            else  "" + lowmin) +
#            "\n" +
#            if showprice_in_bubble then Asdollars(lowday) else "", Color.yellow, no);
#
#
# ============================================
# ============================================

# is hi more recent than lo ?
def ishicloser = (hibarsago < lobarsago);

# ///////////////////////////////////////

AddLabel( ishicloser and d == 1,
# time of peak , hi 1st
 ( "H " + (hihr + ":") + (if himin < 10 then "0" + himin else  "" + himin) +
 " " + (if showprice_in_bubble then Asdollars(highday) else ""))
 + " | " +
 "L " + (lowhr + ":") + (if lowmin < 10 then "0" + lowmin else  "" + lowmin) +
 " " + (if showprice_in_bubble then Asdollars(lowday) else "")
 , (if ishicloser then Color.green else color.red) );


AddLabel( !ishicloser and d == 1,
# time of dip , lo 1st
 ( "L " + (lowhr + ":") + (if lowmin < 10 then "0" + lowmin else  "" + lowmin) +
 " " + (if showprice_in_bubble then Asdollars(lowday) else ""))
 + " | " +
 "H " + (hihr + ":") + (if himin < 10 then "0" + himin else  "" + himin) +
 " " + (if showprice_in_bubble then Asdollars(highday) else "")
 , (if ishicloser then Color.green else color.red) );


AddLabel( ishicloser and d == 2,
## bars since peak , hi 1st
 ( "H " + (if hibarsago < 10 then "0" else "") + hibarsago + " bars " +
 (if showprice_in_bubble then Asdollars(highday) else "") +
 " | " +
 "L " + (if lobarsago < 10 then "0" else "") + lobarsago + " bars " +
 (if showprice_in_bubble then Asdollars(lowday) else "") )
 , (if ishicloser then Color.green else color.red));


AddLabel( !ishicloser and d == 2,
## bars since peak , lo 1st
 ( "L " + (if lobarsago < 10 then "0" else "") + lobarsago + " bars " +
 (if showprice_in_bubble then Asdollars(lowday) else "") +
 " | " +
 "H " + (if hibarsago < 10 then "0" else "") + hibarsago + " bars " +
 (if showprice_in_bubble then Asdollars(highday) else "") )
 , (if ishicloser then Color.green else color.red));
#
#


show bars back and price
iVkcEEA.jpg



show time and price
1A0AHSk.jpg



show time and no price
VewO27B.jpg
 
Last edited:
Example of Plotting Hour:Min Time Stamp at Regular Trading Hours High of Day ( RTH HOD )
By: The one and only Legendary .... Mobius!
Request 01.19.2021
(Zero fix and hours offset by XeoNoX)
Change Hours Offset in the input to HRS you need to adjust for daylight savings or your local timezone


REMEMBER TO THUMBS UP IF YOU FOUND THIS POST USEFUL

NHuvBLW.jpg



Code:
# Example of Plotting Hour:Min Time Stamp at Regular Trading Hours High of Day  ( RTH HOD )
#By Mobius
# Request 01.19.2021
#(Zero fix and hours offset by XeoNoX)
#Change Hours_Offset in the input to HRS you need to adjust for daylight savings or your local timezone
input Hours_Offset = 0;
input Start = 9.5;
input End = 1600;

def h = high;
def c = close;
def x = BarNumber();
def D = 86400;
def Hr = 3600;
def epoch = (GetTime() / 1000);
def hour = ((epoch % D) / Hr); # 5 hour diff for GMT
def roll = if hour > 5
           then hour - 5
           else if hour < 5
           then (hour + 24) - 5
           else 0;
def min = Floor(((epoch % D) % Hr)) / 60;
def RTH_HOD = if roll crosses above Start
              then h
              else if Between(roll, Start, End)
              then Max(h, RTH_HOD[1])
              else RTH_HOD[1];
def HODx;
def HODHr;
def HODmin;
if RTH_HOD == h
{
    HODx = x;
    HODHr = roll;
    HODmin = min;
}
else
{
    HODx = HODx[1];
    HODHr = HODHr[1];
    HODmin = HODmin[1];
}



AddChartBubble(x == HighestAll(HODx), RTH_HOD, if HODmin > 9 then "HOD " +  (RTH_HOD) + "  @" + Floor(HODHr + Hours_Offset) + ":" + HODmin + "AM"  else "Highest Volume Today " +  (RTH_HOD) + "  @" + Floor(HODHr + Hours_Offset) + ":0" + HODmin + "AM" , Color.CYAN);
AddVerticalLine(roll crosses above Start);


AddLabel (yes, if HODmin > 9 then "HOD " +  (RTH_HOD) + "  @" + Floor(HODHr + Hours_Offset) + ":" + HODmin + "AM"  else "Highest Volume Today " +  (RTH_HOD) + "  @" + Floor(HODHr + Hours_Offset) + ":0" + HODmin + "AM"   );
# End Code
Thanks for sharing. How about plotting hour:min time stamp for RTH of Day Low?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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