Edgoro
Compile error · Old code in v6 (v4 and v5 to v6)

Pine Script: Could not find function 'study' (fix)

study() was renamed indicator() in Pine Script v5. How to fix "Could not find function or function reference 'study'" and upgrade an old script to v6.

Pine Editor console · line 2
Could not find function or function reference 'study'

Cause

study() is the declaration statement of Pine Script v4 and earlier. Version 5 renamed it indicator(), so v5 and v6 scripts can't find it.

Broken code

TradingView reports the error on line 2.

Pine Script v6
//@version=6
study("My SMA", overlay = true)
plot(ta.sma(close, 20))

Fixed code

The same script, corrected for Pine Script v6. Paste it into the Pine Editor and save.

Pine Script v6
//@version=6
indicator("My SMA", overlay = true)
plot(ta.sma(close, 20))

Why it works

indicator() takes the same core arguments as study(): title, shorttitle, overlay, format and precision. One argument changed name: if the old call used resolution =, write timeframe = instead, otherwise you get The "indicator" function does not have an argument with the name "resolution".

The rest of a v4 script

A script that still says study() usually has other v4 code that fails in v6:

The Pine Editor can convert a v4 script to v5, and a v5 script to v6, from the "Manage script" menu, as long as the original compiles in its own version.

Questions

What replaced study() in Pine Script?

indicator(), since Pine Script v5. Strategies still use strategy() and libraries use library().

Can I keep //@version=4 to avoid the error?

Yes, a v4 script still runs. But older versions don't get new features, and mixing v4 code with v5 or v6 examples causes more errors. Converting is usually the better long-term choice.

The scripts on this page are minimal examples written to show the error and its fix, not trading systems. Trading involves substantial risk of loss and is not suitable for every investor. Edgoro is a software tool, not a broker or financial adviser: nothing it produces is investment advice, and past or backtested performance does not guarantee future results.

Still getting an error?

Paste your script and the message into the free Pine Script error fixer: it explains what went wrong and returns a corrected v6 version. Or describe the indicator in plain English and let Edgoro write the code.