//@version=5 // Baroq Daily Range Meter. Open source under the Mozilla Public License 2.0, (c) 2026 Baroq Tech. // Compares how far price has moved today with its average daily range over the last days, and draws yesterday's high // and low. Education and chart reading only: it never trades and it is not advice. indicator("Baroq Daily Range Meter", shorttitle="Baroq Range", overlay=true) len = input.int(14, "Average over this many days", minval=1, maxval=200) levels = input.bool(true, "Draw yesterday's high and low") var float tH = na var float tL = na var float yH = na var float yL = na var array ranges = array.new_float() if timeframe.change("D") if not na(tH) yH := tH yL := tL array.push(ranges, tH - tL) if array.size(ranges) > len array.shift(ranges) tH := high tL := low else tH := na(tH) ? high : math.max(tH, high) tL := na(tL) ? low : math.min(tL, low) avg = array.size(ranges) > 0 ? array.avg(ranges) : na used = avg > 0 ? (tH - tL) / avg * 100 : na plot(levels ? yH : na, "Yesterday's high", color=color.new(#e8c36a, 20), style=plot.style_linebr) plot(levels ? yL : na, "Yesterday's low", color=color.new(#e8c36a, 20), style=plot.style_linebr) var table t = table.new(position.top_right, 2, 3, bgcolor=color.new(#0d0d0f, 10), border_color=color.new(#e8c36a, 60), border_width=1) if barstate.islast table.cell(t, 0, 0, "Today's range", text_color=color.silver, text_size=size.small) table.cell(t, 1, 0, str.tostring(tH - tL, format.mintick), text_color=color.white, text_size=size.small) table.cell(t, 0, 1, "Average, " + str.tostring(array.size(ranges)) + " days", text_color=color.silver, text_size=size.small) table.cell(t, 1, 1, str.tostring(avg, format.mintick), text_color=color.white, text_size=size.small) table.cell(t, 0, 2, "Used so far", text_color=color.silver, text_size=size.small) table.cell(t, 1, 2, na(used) ? "-" : str.tostring(used, "#") + "%", text_color=used >= 100 ? #e5534b : #e8c36a, text_size=size.small)