Could not find function or function reference 'study'In v6 study() no longer exists — it was renamed indicator() — and most built-ins now live under namespaces (ta.*, math.*, request.security), so bare v3/v4 calls fail too. Educational content only; not financial advice and no profitability claim.
The parser could not resolve the name 'study' because that declaration was removed after Pine v3/v4 and replaced by indicator(). The same class of error appears for other de-namespaced built-ins carried over from old scripts: bare rsi()/sma()/crossover() must become ta.rsi()/ta.sma()/ta.crossover(), bare security() must become request.security(), and abs()/max() become math.abs()/math.max(). TradingView matches names exactly, including capitalization, so a wrong namespace reads as a missing function.
Change study() to indicator() and add //@version=6 at the top. Then namespace every built-in: ta.* for technical analysis, math.* for math, str.* for strings, request.security for higher-timeframe data. When you pull another timeframe with request.security, offset the series by [1] and pass barmerge.lookahead_off to avoid lookahead bias.
//@version=4
study("Migration demo", overlay=true)
htfClose = security(syminfo.tickerid, "D", close)
plot(sma(htfClose, 20))✓ Validated clean by our own engine
//@version=6
indicator("Migration demo", overlay=true)
htfClose = request.security(syminfo.tickerid, "D", close[1], lookahead=barmerge.lookahead_off)
plot(ta.sma(htfClose, 20), title="HTF SMA20")Educational, code-correctness reference only — not financial advice. Trading involves substantial risk of loss.