T442
record literal without a type name
Severity Error
A brace block with field: value pairs was written without a type name in front of it. Flowscope Script has no anonymous records; each record literal names its type, so the compiler knows its fields.
Declare a type and put its name before the braces: Zone { top: h, bottom: l }.
Failing example
script "Last zone"
data chart = subscribe(data.ohlcv)
type Zone {
top: float
bottom: float
}
state zone: Zone? = null
plot mid = plot.line(title: "Zone midpoint")
on chart.close {
let z = zone
mid.plot(z != null ? (z.top + z.bottom) / 2.0 : null)
zone = { top: chart.high ?? 0.0, bottom: chart.low ?? 0.0 }
}Fixed example
script "Last zone"
data chart = subscribe(data.ohlcv)
type Zone {
top: float
bottom: float
}
state zone: Zone? = null
plot mid = plot.line(title: "Zone midpoint")
on chart.close {
let z = zone
mid.plot(z != null ? (z.top + z.bottom) / 2.0 : null)
zone = Zone { top: chart.high ?? 0.0, bottom: chart.low ?? 0.0 }
}