T403
indicator inputs come from different timeframes
Severity Error
An indicator with several series inputs (for example ta.correlation, ta.crossover) receives series from subscriptions with different timeframes. Their bars do not line up one to one, so the result would compare unrelated periods.
Feed the indicator from subscriptions that share one timeframe, or compute each side on its own timeframe and compare plain values afterwards.
Failing example
script "Price vs OI correlation"
data (
chart = subscribe(data.ohlcv)
oiDaily = subscribe(data.oi, timeframe: 1D)
)
pane p = pane(title: "Correlation", height: 0.2)
plot corr = plot.line(title: "Close/OI correlation", on: p)
on chart.close {
corr.plot(ta.correlation(chart.close, oiDaily.close, 30))
}Fixed example
script "Price vs OI correlation"
data (
chart = subscribe(data.ohlcv)
oi = subscribe(data.oi)
)
pane p = pane(title: "Correlation", height: 0.2)
plot corr = plot.line(title: "Close/OI correlation", on: p)
on chart.close {
corr.plot(ta.correlation(chart.close, oi.close, 30))
}