0

I would like to draw a horizontal line on the opening price of a bar at a certain hour, for example I draw a line on the opening price of the bar at 8 in the morning and it will be updated the next day at the same time. Can anybody help me ?? Thank you

I don't know how to start, if someone can help me I would appreciate it.

2 Answers2

0

You can use the built-in hour and minute variables to figure out if the current bar is 08:00.

Then store the open price in a var variable.

var float open_price = na
is_start = (hour == 8) and (minute == 0)

open_price := is_start ? open : open_price
plot(open_price)
vitruvius
  • 15,740
  • 3
  • 16
  • 26
0

an example

//@version=5 indicator("Cotas Diarias", overlay=true)
_h = 2 // Hour: 7 _m = 0 // Minute: 0 inWindow = (hour(time) == _h) and 
(minute(time) == _m)
var line apertura = na var line R1 = na
if (inWindow) apertura := line.new(bar_index, open, bar_index + 1, open, 
extend=extend.right, color=color.rgb(4, 150, 41), width=4) 
line.delete(apertura[1])

That creates a horizontal line in the opening price of the bar at 8 in the morning and the next day it does the same