Diagnostics
T402
stateful calculation inside a loop
T402
A call that keeps history (such as ta.*) is inside a loop that runs a varying number of times, so the script cannot tell how many copies of that history to keep. This also applies inside a family loop nested in such a loop. Move the call out of the loop.
Failing example
script "conf"
data chart = subscribe(data.ohlcv)
setup family = for tf in [tf("2m"), tf("5m")] {
subscribe(data.ohlcv, timeframe: tf)
}
on chart.update {
for i in 0..2 {
for member in family {
let average = ta.ema(member.close, 3)
}
}
}Corrected example
script "fixed"
data chart = subscribe(data.ohlcv)
on chart.update { let average = ta.ema(chart.close, 3)
for i in 0..2 { let value = average } }