1

I'm trying to figure out how to plot a line from one specific time to another specific time in Pine Script / TradingView.

I'd like to plot from the close price at 14:00 to the close price at 15:30 (exchange time). - If it isn't 15:30 yet, then plot to the close of the most recent bar.

This seems like it should be easy to do, but I can't figure it out. Any help would be greatly appreciated!

Ken White
  • 123,280
  • 14
  • 225
  • 444

1 Answers1

1

Something basic like this could do it

//@version=5
indicator("My script", "t", true)

var line l = na
if hour == 14 and minute == 0
    l := line.new(time, close, time, close, xloc = xloc.bar_time)
if 14 <= hour and (hour < 15 or minute < 30) and hour < 16
    line.set_xy2(l, time, close)
elod008
  • 1,227
  • 1
  • 5
  • 15