I am looking at a futures charts and would like to see the RTH hours range highlighted in a rectangle from the high to the low, for every day except the current day. Can someone help?
I made an attempt but this does not work:
# Highlight Full Regular Trading Hours (RTH) Session
input RTHStartTime = 0930; # 9:30 ET
input RTHEndTime = 1600; # 16:00 ET
def withinRTH =
SecondsFromTime(RTHStartTime) >= 0 and
SecondsTillTime(RTHEndTime) > 0;
def newDay = GetDay() != GetDay()[1];
# Get highest high and lowest low for the entire RTH session
def todayHigh = if withinRTH then HighestAll(high, GetDay()) else Double.NaN;
def todayLow = if withinRTH then LowestAll(low, GetDay()) else Double.NaN;
# Skip current day
def lastDate = HighestAll(GetYYYYMMDD());
def isCurrentDay = GetYYYYMMDD() == lastDate;
def plotHigh = if withinRTH and !isCurrentDay then todayHigh else Double.NaN;
def plotLow = if withinRTH and !isCurrentDay then todayLow else Double.NaN;
plot HighLine = plotHigh;
HighLine.SetDefaultColor(Color.GREEN);
plot LowLine = plotLow;
LowLine.SetDefaultColor(Color.RED);
AddCloud(plotHigh, plotLow, Color.LIGHT_GRAY, Color.LIGHT_GRAY);
Click to expand...
reply to 364
if you want futures, why are you using normal trading hours?
a futures day is 6pm to 5pm. it spans over midnight.
https://tastytrade.com/futures/futures-market-hours/
this shows 3 trading periods. adjust it as needed hilolines_08
https://usethinkscript.com/threads/average-daily-range-indicator-for-thinkorswim.244/#post-66296
this shows 1 period hiloline_07
https://usethinkscript.com/threads/...rkets-for-thinkorswim.14520/page-3#post-58176
-----------------------------
# Highlight Full Regular Trading Hours (RTH) Session
input RTHStartTime = 0930; # 9:30 ET
input RTHEndTime = 1600; # 16:00 ET
futures data is 6pm to 5pm, not 9:30 to 5
def withinRTH =
SecondsFromTime(RTHStartTime) >= 0 and
SecondsTillTime(RTHEndTime) > 0;
def newDay = GetDay() != GetDay()[1];
# Get highest high and lowest low for the entire RTH session
def todayHigh = if withinRTH then HighestAll(high, GetDay()) else Double.NaN;
def todayLow = if withinRTH then LowestAll(low, GetDay()) else Double.NaN;
highestall() only has 1 parameter, not 2.
you would need a different formula within highestall() that defines only 1 period, not multiple days
# Skip current day
def lastDate = HighestAll(GetYYYYMMDD());
def isCurrentDay = GetYYYYMMDD() == lastDate;
if expansion area is visible, this will show a date in the future with no price data
HighestAll(GetYYYYMMDD());
alt,
def lastday = getday() == getlastday();
https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Date---Time/GetLastDay
def plotHigh = if withinRTH and !isCurrentDay then todayHigh else Double.NaN;
def plotLow = if withinRTH and !isCurrentDay then todayLow else Double.NaN;
plot HighLine = plotHigh;
HighLine.SetDefaultColor(Color.GREEN);
plot LowLine = plotLow;
LowLine.SetDefaultColor(Color.RED);
AddCloud(plotHigh, plotLow, Color.LIGHT_GRAY, Color.LIGHT_GRAY);