I want to have on the first bar the bar_index of the last bar available on the chart. The problem is that the last_bar_index is not updated when a new candle starts, ex checking BTCUSDT on 1 min chart
var arr_test_1 = array.new_float()
var arr_test_2 = array.new_float()
if array.size(arr_test_1) > 2
array.shift(arr_test_1)
array.push(arr_test_1, last_bar_index )
// this is not updated when a new bar starts
if bar_index == 0
if array.size(arr_test_2) > 2
array.shift(arr_test_2)
array.push(arr_test_2, last_bar_index )
var label lbl_4 = na
label.delete(lbl_4)
lbl_4 := label.new (barstate.islast ? bar_index : na,
y=close,
xloc=xloc.bar_index,
yloc=yloc.belowbar,
style = label.style_label_up,
size = size.large,
color = color.new(color.aqua, 60),
textcolor = color.new(color.black, 0),
textalign = text.align_left,
text = "arr_test_1 " + str.tostring( arr_test_1 ) + "\narr_test_2 " + str.tostring( arr_test_2 ) + "\nlast_bar_index " + str.tostring( last_bar_index )
)
