Input function to disable script on higher time frame
Posted: Thu Feb 18, 2021 2:02 am
Hello - how would I add an input option to only run a script on a certain time frame. For example, this script, I want it disabled when I switch from a lower time frame to a daily chart. I've seen this input discussed here before but can't find it, again.
If have an article on how to do this that would be helpful, too. I cannot find it on Kodify.
Thank you.
Code: Select all
//@version=4
study(title = "Daily Open Labels", shorttitle = "IntraWeek Lbl", overlay=true)
//Inputs - setting EMA period
showDOPENMon = input(true, title="Monday open - 5 PM EST")
showDOPENTue = input(true, title="Tuesday Open - 5 PM EST")
showDOPENWed = input(true, title="Wednesday Open - 5 PM EST")
showDOPENThur = input(true, title="Thursday Open - 5 PM EST")
showDOPENFri = input(true, title="Friday Open - 5 PM EST")
BarInSession(sess) =>
not na(time(timeframe.period, sess))
// Shape Color selection - central location to edit variable
colDO = color(#2cf93c)
locBB = location.belowbar
styleDO = shape.labelup
txColDO = color.white
sizeHr = size.tiny
// Label Daily Open - 5PM EST. *Daily open is 5 PM the previous day
plotshape(showDOPENMon ? hour == 17 and minute == 0 and dayofweek == dayofweek.sunday : false, title="Sun Open", text="MO", color=#047b0d, location=locBB, style=styleDO, textcolor=txColDO, size=size.small, transp=5)
plotshape(showDOPENTue ? hour == 17 and minute == 0 and dayofweek == dayofweek.monday : false, title="Tue Open", text="TO", color=colDO, location=locBB, style=styleDO, textcolor=txColDO, size=sizeHr, transp=15)
plotshape(showDOPENWed ? hour == 17 and minute == 0 and dayofweek == dayofweek.tuesday : false, title="Wed Open", text="WO", color=colDO, location=locBB, style=styleDO, textcolor=txColDO, size=sizeHr, transp=15)
plotshape(showDOPENThur ? hour == 17 and minute == 0 and dayofweek == dayofweek.wednesday : false, title="Thur Open", text="RO", color=colDO, location=locBB, style=styleDO, textcolor=txColDO, size=sizeHr, transp=15)
plotshape(showDOPENFri ? hour == 17 and minute == 0 and dayofweek == dayofweek.thursday : false, title="Fri Open", text="FO", color=colDO, location=locBB, style=styleDO, textcolor=txColDO, size=sizeHr, transp=15)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
FirstBarOfMonth = dayofmonth(time) < dayofmonth(time)[1]
if FirstBarOfMonth
LabelText = tostring(month(time),"Month ")
LabelAbove = label.new(x=bar_index, y=na, text=LabelText, yloc=yloc.abovebar, color=color.green, textcolor=color.white,
style=label.style_label_down, size=size.small)
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// **** END ***
Thank you.