I want to create a box around the last 5 bars. I only want to draw one box on the chart.
I have written this code, but it doesnt work.
// @version=5
indicator("One Box", overlay=true)
var int left = na
if barstate.islast
left := bar_index-5
top = ta.highest(5)
bottom = ta.lowest(5)
box.new(left= left ,top= top, right= bar_index, bottom= bottom)
Many thanks
New contributor
PineEditor22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.