pine script - How do I plot a horizontal line on the high and low of a specific time in Pinescript? - Stack Overflow
Sat Dec 17 2022 15:37:13 GMT+0000 (Coordinated Universal Time)
Saved by
@ck
//@version=5
indicator("My script", overlay=true, max_lines_count=500)
h = input.int(9, "Hour", minval=0, maxval=59)
m = input.int(30, "Hour", minval=0, maxval=59)
var float first_high = na
var bool can_draw = false
var line l = na
is_new_session = (hour == h) and (minute == m)
bgcolor(is_new_session ? color.new(color.green, 85) : na)
if (is_new_session) // New session
first_high := high // Reset session high
can_draw := true // We are allowed to draw a line
l := line.new(bar_index, first_high, bar_index, first_high, color=color.red) // Get new line id
else
if (can_draw)
if (high > first_high) // New high is made
can_draw := false // Stop drawing
else
line.set_x2(l, bar_index) // Update x2 position of the line (move it to the right)
content_copyCOPY
https://stackoverflow.com/questions/71595917/how-do-i-plot-a-horizontal-line-on-the-high-and-low-of-a-specific-time-in-pinesc
Comments