◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Home / Pine errors / Namespace/v6
Pine Script v6 error · Namespace/v6

Pine Script v6 "Could not find function or function reference 'study'" — v5→v6 migration fix

The error
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.

Why it happens

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.

How to fix it

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.

What triggers it

//@version=4
study("Migration demo", overlay=true)
htfClose = security(syminfo.tickerid, "D", close)
plot(sma(htfClose, 20))

The fix, in code

✓ 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")

Related errors

Educational, code-correctness reference only — not financial advice. Trading involves substantial risk of loss.

Catch the bug that compiles.Run auditGet Pro