Highlight defined time range on chart

wilmanv

Member
VIP
Is there any script that shows me the charts only for a certain time that I define, sample: just betwen 9:00 to 10:00 AM or 2:00 to 4:00PM, for any timeframe: 2 min, 5min, daily, weekly. thanks
 

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
Here is a simple script that lets you highlight a defined time.

Code:
# TS_TRADEZONES
# http://www.thinkscripter.com
# [email protected]
# Last Update 30 JUN 2009

input zoneStart = 1500;
input zoneEnd = 1615;
input type = {default NOTRADE, REVERSAL};
plot highBar;
plot lowBar;

switch (type){

case NOTRADE:
highBar = if secondsTillTime(zoneStart) <= 0 and secondsTillTime(zoneEnd) >= 0 then highestAll(high) else double.nan;
lowBar = if secondsTillTime(zoneStart) <= 0 and secondsTillTime(zoneEnd) >= 0 then lowestAll(low) else double.nan;

case REVERSAL:
lowBar = if secondsTillTime(zoneStart) <= 0 and secondsTillTime(zoneEnd) >= 0 then highestAll(high) else double.nan;
highBar = if secondsTillTime(zoneStart) <= 0 and secondsTillTime(zoneEnd) >= 0 then lowestAll(low) else double.nan;
}
highBar.assignValueColor(if highBar>lowBar then color.dark_red else color.green);
lowBar.assignValueColor(if highBar>lowBar then color.dark_red else color.green);
addCloud(lowBar, highBar);
#---------------- End Of Code --------------------
 

tomsk

Well-known member
VIP
@BenTen This is probably the best way to highlight via an AddCloud the times of day one would be interested in. Run this on a 5 min chart for example

Code:
# Add Cloud Time Based
# tomsk
# 12.16.2019

declare hide_on_daily;

input Time1 = 1100;
input Time2 = 1330;

def active = SecondsTillTime(Time1) <= 0 and SecondsTillTime(Time2) >= 0;
AddCloud(if active then Double.NEGATIVE_INFINITY else Double.NaN, Double.POSITIVE_INFINITY, Color.Gray, Color.Gray);
# End Add Cloud Time Based
 
Last edited:

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.
Top