How does the history reference (e.g. [1]) work on UDTs defined with the var keyword in the new Pine Script version 6?
It works fine when it's defined without the var keyword, but I cannot get it to work with it. I've made a simple example script to demonstrate this. The history reference behaves as I expect if I remove the var in the declaration, but not with it. Do you know what the problem is?
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mickes
//@version=6
indicator("Test history", overlay = true)
type A
int B
var a = A.new()
a.B := bar_index
if not barstate.isfirst
label.new(bar_index, high, str.format("{0} == {1}\n{2} != {3}", (a[1]).B, a.B, bar_index[1], bar_index))