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.
//@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.
//@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:
- functions without their namespace, such as
sma()instead ofta.sma(): see Could not find function or function reference; security()instead ofrequest.security(): see Could not find function 'security';- the
transpargument, replaced bycolor.new(): see no argument named transp.
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.