Preferred time slots

congamike

New member
I've been studying the ICT Mentorship program in youtube. He recommends that there are good times and less preferred times to place entries.
Is it possible to create a Lower Study that draws a line/box/something to start and stop at certain times of the day? (I tried but couldn't figure it out.)
 
I've been studying the ICT Mentorship program in youtube. He recommends that there are good times and less preferred times to place entries.
Is it possible to create a Lower Study that draws a line/box/something to start and stop at certain times of the day? (I tried but couldn't figure it out.)

this will draw 4 purple shaded rectangles, on the desired time periods, on a lower chart.
there are 4 pairs of start/stop times, to define the periods.

if you enter a time that is not a multiple of the chart time, that period won't be shaded.
( 10:04 on a 5 minute chart )

Code:
# shade_time_periods_02

# shade time periods, during a day

# https://usethinkscript.com/threads/preferred-time-slots.12736/
# Preferred time slots   congamike  9/19

#------------------------------------
#if you want the shading to be on the upper chart

# .. disable this line ( by adding a  #  in front of it )
declare lower;
# .. and disable this plot
plot z = 0;
z.setdefaultcolor(color.black);

#------------------------------------

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;

# define a color for all the time periods
DefineGlobalColor( "shade1" , color.violet);


# define time periods (EST)
#/////////////////////////////////////
# copy this code segment for as many periods as desired, and change the variable names
input start1 = 1000;
input end1 = 1030;
def period1 = if SecondsFromTime(start1) >= 0 and SecondsTillTime(end1) > 0 then 1 else 0;
addcloud( (if period1 then pos else na), neg,  GlobalColor( "shade1" ));
#/////////////////////////////////////

input start2 = 1130;
input end2 = 1200;
def period2 = if SecondsFromTime(start2) >= 0 and SecondsTillTime(end2) > 0 then 1 else 0;
addcloud( (if period2 then pos else na), neg,  GlobalColor( "shade1" ));

input start3 = 1330;
input end3 = 1400;
def period3 = if SecondsFromTime(start3) >= 0 and SecondsTillTime(end3) > 0 then 1 else 0;
addcloud( (if period3 then pos else na), neg,  GlobalColor( "shade1" ));

input start4 = 1500;
input end4 = 1530;
def period4 = if SecondsFromTime(start4) >= 0 and SecondsTillTime(end4) > 0 then 1 else 0;
addcloud( (if period4 then pos else na), neg,  GlobalColor( "shade1" ));
#
#

VVlkvos.jpg



-------------------------------------------------------

this code is some notes that may help with,
..drawing vertical lines,
..creating a custom color,
..defining times / time periods

Code:
#------------------------

# create a custom color
#  70,70,70 is light gray
#input color_red_num1 = 70;
#input color_green_num1 = 70;
#input color_blue_num1 = 170;
#DefineGlobalColor( "shade1" , CreateColor( color_red_num1, color_green_num1, color_blue_num1));
#AddCloud(hiline, loline,  GlobalColor( "shade1" ),  GlobalColor( "shade1" ));

# ref
# hex color picker
#  https://www.w3schools.com/colors/colors_picker.asp


#input show_start_verticalline = no;
#input show_end_verticalline = no;
#AddVerticalLine(show_start_verticalline and start1, "start", Color.CYAN);
#AddVerticalLine(show_end_verticalline and end1, "end", Color.CYAN);


# is current bar before normal trading hours?
#def before = if SecondsTillTime(start) > 0 then 1 else 0;
# is current bar during normal trading hours?
#def daytime = if SecondsFromTime(start) >= 0 and SecondsTillTime(end) > 0 then 1 else 0;
# is current bar after normal trading hours?
#def after = if SecondsFromTime(end) > 0 then 1 else 0;

#def start1 = if SecondsTillTime(start) == 0 then 1 else 0;
#def end1 = if SecondsFromTime(end) == 0 then 1 else 0;
#
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
383 Online
Create Post

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