// Variables for lines and labels var line high_line = na var line low_line = na var line open_line = na var line close_line = na
var label high_label = na var label low_label = na var label open_label = na var label close_label = na
// Reset lines and labels at the start of a new day is_new_day = (ta.change(time("D"))) if is_new_day // Delete old lines if na(high_line) == false line.delete(high_line) if na(low_line) == false line.delete(low_line) if na(open_line) == false line.delete(open_line) if na(close_line) == false line.delete(close_line)
// Delete old labels if na(high_label) == false label.delete(high_label) if na(low_label) == false label.delete(low_label) if na(open_label) == false label.delete(open_label) if na(close_label) == false label.delete(close_label)
// Draw new lines and labels if show_high high_line := line.new(bar_index, prev_high, bar_index + 1, prev_high, color=high_color, width=line_width, extend=extend.right) high_label := label.new(bar_index, prev_high, str.tostring(prev_high), style=label.style_label_right, color=high_color, textcolor=color.white)