I would like to draw a vertical line, every day at a certain local time (e.g. 08:00 GMT+1).
Since my last post about vertical lines, pine-script has been updated to
One version of the timestamp() function can use a timezone parameter:
//@version=4
study("Line at time", overlay=true)
targetTime = timestamp("GMT+1", year, month, dayofmonth, 08, 00, 00)
bgcolor(targetTime == time ? color.silver : na, transp = 0)
// Debugging: these plots lines in separate window
plot(targetTime, "targetTime", color.orange)
plot(time, "time")
Chart is shown with UTC+1 times and indicator is set to "No Scale" not to disrupt price scale:
With this version you can choose:
//@version=4
study("Line at time",overlay=true)
fromHour = input(7)
toHour = input(10)
weekdaysOnly = input(true)
useVline = input(false)
dayIsOk = not weekdaysOnly or (dayofweek != dayofweek.saturday and dayofweek != dayofweek.sunday)
t1 = timestamp("GMT+2", year, month, dayofmonth, fromHour, 00, 00)
t2 = timestamp("GMT+2", year, month, dayofmonth, toHour, 00, 00)
timeIsOk = (time >= t1) and (time <= t2)
bgcolor( not useVline and timeIsOk and dayIsOk ? color.orange : na, transp = 80)
if useVline and timeIsOk and dayIsOk
line.new(bar_index, low * .9999, bar_index, high * 1.0001, xloc.bar_index, extend.both, #FF8000ff, line.style_solid, 1)