see if the high is at the beginning or at a different hour.

New member
I'm new at this so please be patient. I'm trying to make a script for the scan. I want to show what hour the high so far has been. the idea is to see if the high is at the beginning or at a different hour. It would be nice if the script return what our or even just a number like say 10 am = 1 and 11 am 2 ... I am trying to test a theory but doing it in my head is kind of slow. I need thinkscript to process this faster.

Solution
This one was kinda fun to throw together.

Code:
``````declare upper;

def t = getTime() % (360 * 1 * 10000);

def h = if secondsFromTime(0930) == 0 then 9 + tz_adjust else if t == 0 then h[1] + 1 else h[1];

def high_of_day = if secondsFromTime(0930) == 0 then high else if high > high_of_day[1] then high else high_of_day[1];

def time_of_hod = if high_of_day != high_of_day[1] then h else time_of_hod[1];

AddLabel(yes, "  High occurred in the " + time_of_hod + " o'clock hour.   ", color.black);``````

Note that I am in the pacific time zone, so my tz_adjust (to get local time from East Coast time) is -3. If you're on the eastern seaboard, just set it to 0. If you're in Hawaii, good on ya and get some more sleep rather...
This one was kinda fun to throw together.

Code:
``````declare upper;

def t = getTime() % (360 * 1 * 10000);

def h = if secondsFromTime(0930) == 0 then 9 + tz_adjust else if t == 0 then h[1] + 1 else h[1];

def high_of_day = if secondsFromTime(0930) == 0 then high else if high > high_of_day[1] then high else high_of_day[1];

def time_of_hod = if high_of_day != high_of_day[1] then h else time_of_hod[1];

AddLabel(yes, "  High occurred in the " + time_of_hod + " o'clock hour.   ", color.black);``````

Note that I am in the pacific time zone, so my tz_adjust (to get local time from East Coast time) is -3. If you're on the eastern seaboard, just set it to 0. If you're in Hawaii, good on ya and get some more sleep rather than trading so early. ;-P

-mashume

Not the exact question you're looking for?

87k+ Posts
386 Online

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?