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:

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

I am looking to add a couple custom filters to my watchlist column to export and track.

I am wanting to get timestamps for the intraday high and low. In the watchlist it might say "time of top tick" - "time of bottom tick".

I don't want to include premarket or after hours which TOS includes in their high and low.

I am wondering if anyone has code or has found the intraday high, low, close and the times of the high and low.

A bonus would be if anyone has scripts for finding total premarket volume, as well as finding the premarket high and low.

Thanks!
 
Hello, I have no experience with thinkscript but some little experience with Python (if that information helps).

I was wondering how to write script to show what time a specific event occurred like the intraday HOD, LOD, Pre-market HOD and any other custom variables I've created. This is mostly for the daily chart just so I could find the data faster and save a lot of time.

Thanks for the help!
 
I would like a study that would time stamp/highlight/checkmark the first 30-minute aggregation period bar closed if it’s greater than or equal to VWAP.

I have a similar code for the study being highlighted if the price is over vwap.
{
plot....
Indicator....
Addlabel().....

//Im typing this code on top of my head, but once ill get home from work, ill elaborate more.

Assignbackgroundcolor(if

bid is greater than or equal to vwap then color.yellow else color.black);
}

//so instead of this, I want a specific time which is the first bar in 30-minute aggregation period to be able to stamp/record whether the price went over the vwap or not. Not disappear, but have it recorded. Preferably on the watchlist because if it was on the chart, I would have to look at the stock’s chart. The purpose of this code is to help me eliminate or cherrypick what I believe is bullish by just looking at my watchlist and seeing the study/script that indicates that the certain stock at a specific time went over VWAP. This will be a tremendous help for me because I am a big believer of VWAP.
 
@Stoynks here you go, if close is over 30 minute vwap it ill be green, if its lower then red.

This only works correctly on 30 min Chart timeframe/aggregation

Code:
declare upper;

input pointInTime = 0929;

def isAppointedHour = if SecondsFromTime(pointInTime) > 0 then 1 else 0;

def vwapAtTime = if isAppointedHour == 1 and isAppointedHour[1] == 0 then vwap
    else if isAppointedHour == 1 then vwapAtTime[1]
        else Double.NaN;



AddLabel (yes, "  Todays 30Min Vwap " +  (vwapAtTime),(if close>vwapAtTime then color.green else color.red));
 
Hello, I want the 30 minute close over the vwap (day) instead, would that be possible?
you'll have to explain more with a picture and example..

30 minute close over the vwap (day)... what are you trying to achieve at that reference?

your missing data in what you are trying to do?
 
avdlsJc.png


I have a similar code;

Code:
}
plot indicator = double.NaN;

AddLabel (yes, indicator, Color.BLACK);

AssignBackgroundColor(if

close is greater than or equal to reference VWAP()."VWAP" then color.yellow else color.black);
}

I want the exact same thing instead of every time close is over vwap, I only want the first bar when the market opens for it to be recorded on my watchlist. Sorry, idk how to explain it. hopefully, it makes more sense haha.
 
So if the price is above VWAP at 10:00 you want the cell colored...??? With or without price...??? Not every chart will be on a 30 minute candle timeframe... Or does it absolutely have to be the close of a 30 minute candle...??? We kinda wanna look at versatility here...
 
"every time close is over vwap, I only want the first bar when the market opens for it to be recorded on my watchlist"

That means when the close is above vwap, that can be done with a normal built in scanner. if you cant explain, its cant be coded.
 
So if the price is above VWAP at 10:00 you want the cell colored...??? With or without price...??? Not every chart will be on a 30 minute candle timeframe... Or does it absolutely have to be the close of a 30 minute candle...??? We kinda wanna look at versatility here...
Yeah, exactly that. I just want the cell colored if the price is above VWAP at 10:00. I don't need the price, the purpose is just to indicate only that one time if it reached vwap or not. sorry if im not explaining correctly.
"every time close is over vwap, I only want the first bar when the market opens for it to be recorded on my watchlist"

That means when the close is above vwap, that can be done with a normal built in scanner. if you cant explain, its cant be coded.
yeah close is above vwap, but at a specific time which is 10:00am. how would I code that?
 
@Stoynks If you want to give it a go, try checking out any of the many Opening Range Breakout (ORB) scripts here in the forums... They should supply the time range and price at time logic you need...

Edited to add: @XeoNoX may have provided you with adequate code in your other topic...
 
Here is the Code for VWAP at specific time, you can change the time via the input

NOTE: For this to work the chart aggregation must be divisible by time interval you choose ... in other words you can not choose 3 minute interval in the study and place it on a 10 min chart as the calculations wont be correct.

Dont forget to hit the like button if you find my post useful.

Code:
#time input must match agregation of your chart (chart time frame must be divisable by time interval specified)
#by XeoNoX via usethinkscript.com
input Opentime = 0950;
input Endtime = 1000;
def na = Double.NaN;
def GetTime = if GetLastDay() == GetDay() and SecondsFromTime(Opentime) >= 0 and SecondsFromTime(Endtime) <
0 then 1 else 0;
def LastPoint = !IsNaN(close) and IsNaN(close[-1]);
def Valuepoint = HighestAll(if GetTime and  !LastPoint then vwap else 0);
def vwap_at_time =  if  GetTime  and vwap == Valuepoint then vwap else vwap_at_time[1];
plot scan = close > vwap_at_time;
AddLabel (yes, "VWAP at " + (astext(Endtime))+ "EST" +" =  " + vwap_at_time);
 
Hi there,

I've tried adding Get(time) to my thinkscript to get a timestamp of a candle stick but it displays it in seconds. Is there a way to convert this to an hour:min (for example 11:15)?

Thanks!
 
Hi there,

I've tried adding Get(time) to my thinkscript to get a timestamp of a candle stick but it displays it in seconds. Is there a way to convert this to an hour:min (for example 11:15)?

Thanks!

We are somewhat limited in how we can manipulate Date and Time within Thinkscript... Members have been creative, however, so perhaps you can find some code that suits your needs using the search feature... I find Date and Time frustrating due to the limitations... Another good resource of information is the TOS and Thinkscript Snippet Collection compiled by Jim Shingler...
 
Hi there,

I've tried adding Get(time) to my thinkscript to get a timestamp of a candle stick but it displays it in seconds. Is there a way to convert this to an hour:min (for example 11:15)?

Thanks!

The following code plots bubbles with the time associated with the bar referenced. Also, included is code to limit the number of bubbles displayed, as well as, an example of how to offset a bubble, both up/down and sideways, and a way to draw a line from this bubble to the bar it is referencing. The code uses Gettime() and RegularTradingStart() functions to determine the time displayed.
Code:
#Example Time_Gettime
#Sleepz 20210315
#Usethinkscript request

#Time Stamp based upon Gettime and RegularTradingStart. Choose timezone
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;

#Example : Bubble showing current time of last bar displayed

input showBubble_lastbar = no;

AddChartBubble(showBubble_lastbar and IsNaN(close[-1]), low, hour + ":" + (if minutes < 10 then "0" else "") + minutes, Color.WHITE, no);


#Bubbles showing time stamp 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 ExpAverage(close, 3) crosses below ExpAverage(close, 13) 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];

AddChartBubble(showBubbles_Limited_by_Count and HighestAll(dataCount) - dataCount != 0 and       HighestAll(dataCount) - dataCount - 1 <= bubble_limit - 2 and !IsNaN(hour) and !IsNaN(cond[1]) == 0 and !IsNaN(cond) == 1,
    high + TickSize() * updown_bubblemover,
    hour + ":" +
    if minutes < 10
    then "0" + minutes
    else "" + minutes , Color.WHITE, yes);


#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(dataCountb) - dataCountb <= 0 and !IsNaN(hour[b]) == 1 and  !IsNaN(cond[b1]) == 0 and !IsNaN(cond[b]) == 1,
    high[b1] + TickSize() * updown_bubblemover,
    hour[b]  + ":" +
    if minutes[b] < 10
    then "0" + minutes[b]
    else "" + minutes[b] , Color.WHITE, yes);

plot hh  = if HighestAll(dataCount) - dataCount <= 1 - 1 and !IsNaN(cond) == 1
           then high
           else Double.NaN;
plot hh1 = if HighestAll(dataCountb) - dataCountb <= 1 - 1 and !IsNaN(cond[b]) == 1
           then high[b1] + 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);
 
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
 
Last edited:
The following code plots bubbles with the time associated with the bar referenced. Also, included is code to limit the number of bubbles displayed, as well as, an example of how to offset a bubble, both up/down and sideways, and a way to draw a line from this bubble to the bar it is referencing. The code uses Gettime() and RegularTradingStart() functions to determine the time displayed.
Code:
#Example Time_Gettime
#Sleepz 20210315
#Usethinkscript request

#Time Stamp based upon Gettime and RegularTradingStart. Choose timezone
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;

#Example : Bubble showing current time of last bar displayed

input showBubble_lastbar = no;

AddChartBubble(showBubble_lastbar and IsNaN(close[-1]), low, hour + ":" + (if minutes < 10 then "0" else "") + minutes, Color.WHITE, no);


#Bubbles showing time stamp 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];

AddChartBubble(showBubbles_Limited_by_Count and HighestAll(dataCount) - dataCount != 0 and       HighestAll(dataCount) - dataCount - 1 <= bubble_limit - 2 and !IsNaN(hour) and !IsNaN(cond[1]) == 0 and !IsNaN(cond) == 1,
    high + TickSize() * updown_bubblemover,
    hour + ":" +
    if minutes < 10
    then "0" + minutes
    else "" + minutes , Color.WHITE, yes);


#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(dataCountb) - dataCountb <= 0 and !IsNaN(hour[b]) == 1 and  !IsNaN(cond[b1]) == 0 and !IsNaN(cond[b]) == 1,
    high[b1] + TickSize() * updown_bubblemover,
    hour[b]  + ":" +
    if minutes[b] < 10
    then "0" + minutes[b]
    else "" + minutes[b] , Color.WHITE, yes);

plot hh  = if HighestAll(dataCount) - dataCount <= 1 - 1 and !IsNaN(cond) == 1
           then high
           else Double.NaN;
plot hh1 = if HighestAll(dataCountb) - dataCountb <= 1 - 1 and !IsNaN(cond[b]) == 1
           then high[b1] + 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);
This is honestly amazing, thank you so much! For the drawing the candle, if i wanted to put the code below instead of the time stamp, is there an easy way of just adding this in?

def A = hl2;
AddChartBubble(Volume == HighestAll(volume), A, "$" + A, Color.light_gray);

Is there a way to add these chart bubbles onto a custom made study that's on a "lower"? I know i can add it to the volume section using "declare on_volume;" but i wasn't able to figure it out on a custom made study
 
Last edited:
you can overlay the study (just add it) with other studies or you can just copy and paste the code into existing code and remove AddChartBubble, Addlabel or AddVerticalLine as needed. keep in mind you may end up with scaling issues.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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