Display Labels at Specific Times of Day

Amused to Death

New member
What would be the correct syntax for displaying different labels at specific times of day? Labels might indicate "premarket," "day open," "European close," etc. I've found scripts for drawing vertical lines at various times, but nothing for displaying labels instead.

Say I wanted to display labels representing various "zones," with each label remaining on an intraday chart until the next time zone is reached:

0000 to 0700 "Zone 1"
0700 to 0930 "Zone 2"
0930 to 1130 "Zone 3"
1130 to 1330 "Zone 4"
1330 to 1600 "Zone 5"
1600 to 2000 "Zone 6"
2000 to 2230 "Zone 7"
2230 to 0000 "Zone 8"

In this example, with all 24 hours in a day accounted for, there should never be a time when a "zone" label isn't being displayed on an intraday chart.

An (on/off) option to include vertical lines between each of these zones would be nice, but the labels are the primary focus.

I'm new to ThinkScript (and this forum — my first post!), so any/all help is appreciated!
 
Solution
What would be the correct syntax for displaying different labels at specific times of day? Labels might indicate "premarket," "day open," "European close," etc. I've found scripts for drawing vertical lines at various times, but nothing for displaying labels instead.

Say I wanted to display labels representing various "zones," with each label remaining on an intraday chart until the next time zone is reached:

0000 to 0700 "Zone 1"
0700 to 0930 "Zone 2"
0930 to 1130 "Zone 3"
1130 to 1330 "Zone 4"
1330 to 1600 "Zone 5"
1600 to 2000 "Zone 6"
2000 to 2230 "Zone 7"
2230 to 0000 "Zone 8"

In this example, with all 24 hours in a day accounted for, there should never be a time when a "zone" label isn't being displayed on an intraday...
What would be the correct syntax for displaying different labels at specific times of day? Labels might indicate "premarket," "day open," "European close," etc. I've found scripts for drawing vertical lines at various times, but nothing for displaying labels instead.

Say I wanted to display labels representing various "zones," with each label remaining on an intraday chart until the next time zone is reached:

0000 to 0700 "Zone 1"
0700 to 0930 "Zone 2"
0930 to 1130 "Zone 3"
1130 to 1330 "Zone 4"
1330 to 1600 "Zone 5"
1600 to 2000 "Zone 6"
2000 to 2230 "Zone 7"
2230 to 0000 "Zone 8"

In this example, with all 24 hours in a day accounted for, there should never be a time when a "zone" label isn't being displayed on an intraday chart.

An (on/off) option to include vertical lines between each of these zones would be nice, but the labels are the primary focus.

I'm new to ThinkScript (and this forum — my first post!), so any/all help is appreciated!

Try this

Ruby:
input showlabels = yes;

AddLabel(showlabels and SecondsFromTime(0000) >= 0 and SecondsTillTime(0700) > 0, "Zone 1", Color.WHITE);
AddLabel(showlabels and SecondsFromTime(0700) >= 0 and SecondsTillTime(0930) > 0, "Zone 2", Color.WHITE);
AddLabel(showlabels and SecondsFromTime(0930) >= 0 and SecondsTillTime(1130) > 0, "Zone 3", Color.WHITE);
AddLabel(showlabels and SecondsFromTime(1130) >= 0 and SecondsTillTime(1330) > 0, "Zone 4", Color.WHITE);
AddLabel(showlabels and SecondsFromTime(1330) >= 0 and SecondsTillTime(1600) > 0, "Zone 5", Color.WHITE);
AddLabel(showlabels and SecondsFromTime(1600) >= 0 and SecondsTillTime(2000) > 0, "Zone 6", Color.WHITE);
AddLabel(showlabels and SecondsFromTime(2000) >= 0 and SecondsTillTime(223) > 0, "Zone 7", Color.WHITE);
AddLabel(showlabels and SecondsFromTime(2230) >= 0 and SecondsTillTime(0000) > 0, "Zone 8", Color.WHITE);

input showverticals = yes;

AddVerticalLine(showverticals and SecondsFromTime(0000) == 0, "Zone 1", Color.WHITE);
AddVerticalLine(showverticals and SecondsFromTime(0700) == 0, "Zone 2", Color.WHITE);
AddVerticalLine(showverticals and SecondsFromTime(0930) == 0, "Zone 3", Color.WHITE);
AddVerticalLine(showverticals and SecondsFromTime(1130) == 0, "Zone 4", Color.WHITE);
AddVerticalLine(showverticals and SecondsFromTime(1330) == 0, "Zone 5", Color.WHITE);
AddVerticalLine(showverticals and SecondsFromTime(1600) == 0, "Zone 6", Color.WHITE);
AddVerticalLine(showverticals and SecondsFromTime(2000) == 0, "Zone 7", Color.WHITE);
AddVerticalLine(showverticals and SecondsFromTime(2230) == 0, "Zone 8", Color.WHITE);
 
Solution

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