Labels to tell what time frame is closing at a certain time.

kingkunta

New member
Want to find a program that starts/runs from market open

I want for every minute that passes from 9:30 to 16:00, for the label to highlight what time frame closes at that time.
Using these time frames ->
1,2,3,5,10,15,30,60,240


Some examples,

If the time was 9:43, It would light up the time frames shown

1, 2, 3

If the time was 9:45, It would show this

1, 3, 5, 15

If the time was 13:00 , It would show this

1, 2, 3, 5, 10, 15, 30, 60, 240


Thanks in advance for any help!
 
Solution
Want to find a program that starts/runs from market open

I want for every minute that passes from 9:30 to 16:00, for the label to highlight what time frame closes at that time.
Using these time frames ->
1,2,3,5,10,15,30,60,240

this will show labels for the listed time periods
can choose to,
.. always show the numbers ( valid numbers are yellow, others are gray),
.. or just the valid numbers

i picked 9:00 am as the starting time, to base the time calcs from.

there are 2 test codes that can be turned on to see some values.

Ruby:
# closing_time_frame_labels_0c

# https://usethinkscript.com/threads/labels-to-tell-what-time-frame-is-closing-at-a-certain-time.11870/
#I want for every minute that passes from 9:30 to 16:00, for the...
Want to find a program that starts/runs from market open

I want for every minute that passes from 9:30 to 16:00, for the label to highlight what time frame closes at that time.
Using these time frames ->
1,2,3,5,10,15,30,60,240

this will show labels for the listed time periods
can choose to,
.. always show the numbers ( valid numbers are yellow, others are gray),
.. or just the valid numbers

i picked 9:00 am as the starting time, to base the time calcs from.

there are 2 test codes that can be turned on to see some values.

Ruby:
# closing_time_frame_labels_0c

# https://usethinkscript.com/threads/labels-to-tell-what-time-frame-is-closing-at-a-certain-time.11870/
#I want for every minute that passes from 9:30 to 16:00, for the label to highlight what time frame closes at that time.
#Using these time frames -> 1,2,3,5,10,15,30,60,240

input show_just_valid_times = no;
def sh = !show_just_valid_times;

def start_time = 0900;
def xsec =  SecondsFromTime(start_time);
def xmin = xsec / 60;

input t01 = 1;
input t02 = 2;
input t03 = 3;
input t05 = 5;
input t10 = 10;
input t15 = 15;
input t30 = 30;
input t60 = 60;
input t240 = 240;

def v01 = (xmin % t01 == 0);
def v02 = (xmin % t02 == 0);
def v03 = (xmin % t03 == 0);
def v05 = (xmin % t05 == 0);
def v10 = (xmin % t10 == 0);
def v15 = (xmin % t15 == 0);
def v30 = (xmin % t30 == 0);
def v60 = (xmin % t60 == 0);
def v240 = (xmin % t240 == 0);


addlabel(1, " ", color.black);
addlabel(sh or v01, "1", (if v01 then color.yellow else color.gray));
addlabel(sh or v02, "2", (if v02 then color.yellow else color.gray));
addlabel(sh or v03, "3", (if v03 then color.yellow else color.gray));
addlabel(sh or v05, "5", (if v05 then color.yellow else color.gray));
addlabel(sh or v10, "10", (if v10 then color.yellow else color.gray));
addlabel(sh or v15, "15", (if v15 then color.yellow else color.gray));
addlabel(sh or v30, "30", (if v30 then color.yellow else color.gray));
addlabel(sh or v60, "60", (if v60 then color.yellow else color.gray));
addlabel(sh or v240, "240", (if v240 then color.yellow else color.gray));

#--------------------------------------
input test1 = no;
addlabel(test1, " ", color.black);
addlabel(test1, xmin, color.cyan);

addlabel(test1, t01 + " " + v01, (if v01 then color.yellow else color.gray));
addlabel(test1, t02 + " " + v02, (if v02 then color.yellow else color.gray));
addlabel(test1, t03 + " " + v03, (if v03 then color.yellow else color.gray));
addlabel(test1, t05 + " " + v05, (if v05 then color.yellow else color.gray));
addlabel(test1, t10 + " " + v10, (if v10 then color.yellow else color.gray));
addlabel(test1, t15 + " " + v15, (if v15 then color.yellow else color.gray));
addlabel(test1, t30 + " " + v30, (if v30 then color.yellow else color.gray));
addlabel(test1, t60 + " " + v60, (if v60 then color.yellow else color.gray));
addlabel(test1, t240 + " " + v240, (if v240 then color.yellow else color.gray));


def r01 = (xmin % t01);
def r02 = (xmin % t02);
def r03 = (xmin % t03);
def r05 = (xmin % t05);
def r10 = (xmin % t10);
def r15 = (xmin % t15);
def r30 = (xmin % t30);
def r60 = (xmin % t60);
def r240 = (xmin % t240);

input test2 = no;
addchartbubble(test2, low,
xmin  + "\n" +
r01 + "\n" +
r02 + "\n" +
r03 + "\n" +
r05 + "\n" +
r10 + "\n" +
r15 + "\n" +
r30 + "\n" +
r60 + "\n" +
r240
, color.yellow, no);
#
 
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
427 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