Highlight defined time range on chart

wilmanv

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

BenTen

Administrative
Staff
VIP
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 --------------------
 
wilmanv

wilmanv

Member
VIP
Thanks, @BenTen , is possible just show that time , the rest of hours off or no visualize, thanks
 
T

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:
evanevans

evanevans

Member
Anybody know of a script to show/highlight certain times of the trading day? Like morning, mod-day, and closing, etc?
 

Similar threads

Top