Diagnostics
T419
alias must refer directly to one declared scale, window, pane, or alert
T419
Color scales, windows, panes, and alerts must each be bound to exactly one declaration. Bind the resource once (for example, color.scale(...) during setup or a window/pane/alert declaration) and use that name directly, never a conditional, collection, or call selection.
Failing example
script "conf"
input (
useAlt = input.bool(false, title: "alt")
)
setup heat = color.scale(at: [0.0, 1.0], colors: [color.red, color.green])
setup cool = color.scale(at: [0.0, 1.0], colors: [color.green, color.red])
setup arr = [heat, cool]
setup sel = if useAlt color.scale(at: [0.0, 1.0], colors: [color.red, color.green])
data chart = subscribe(data.ohlcv)
plot out = plot.line(title: "out")
on chart.update {
let pick = chart.close > 0.0 ? heat : cool
out.plot(pick.sample(0.5))
out.plot(arr[0].sample(0.5))
out.plot(sel.sample(0.5))
}Corrected example
script "fixed"
setup scale = color.scale(at: [0.0, 1.0], colors: [#000000, #ffffff])
data chart = subscribe(data.ohlcv)
on chart.update { let color = scale.sample(chart.close ?? 0.0) }