I am new to pine code and i want to draw lines (horizontal) on second 5 min candle high and low, however i want to fix this timeframe in strategy. Currently in below code, if i view the chart in 3 min, strategy changes to 3 min high low.. I want it to be fixed for 5 min irrespective of whatever is being viewed. Can someone help?
//@version=5
indicator("opentime", shorttitle="OPENTIME", overlay=true)
import PineCoders/VisibleChart/3 as ch
var lines = array.new_line()
var labels = array.new_label()
var barnum = 0
var _low = low
var _high = high
if session.isfirstbar
barnum := bar_index
if barstate.isconfirmed and bar_index == barnum + 1
_low := low
_high := high
if barstate.isconfirmed and bar_index == barnum + 1
_low := math.min(low, _low)
_high := math.max(high, _high)
rightmost_bar = ch.rightBarIndex()
// clear labels
for lb in labels
label.delete(lb)
// clear lines
for ln in lines
line.delete(ln)
array.clear(lines)
array.clear(labels)
array.push(lines, line.new(bar_index - 1, _low, bar_index, _low, style=line.style_solid, extend=extend.both, color=color.new(#8f9197, 1), width=1))
array.push(labels, label.new(rightmost_bar - 1, _low, text="Low: " + str.tostring(_low), color=color.new(#F5F5EC,1), style=label.style_label_upper_right, textalign=text.align_right))
array.push(lines, line.new(bar_index - 1, _high, bar_index, _high, style=line.style_solid, extend=extend.both, color=color.new(#8f9197, 1), width=1))
array.push(labels, label.new(rightmost_bar - 1, _high, text="High: " + str.tostring(_high), color=color.new(#F5F5EC,1), style=label.style_label_upper_right, textalign=text.align_right))
I tried changing it by keeping a variable but not sure to implement. Tried ChatGPT but not getting right direction.