Cause
security() is the v4 name of the function that requests data from another symbol or timeframe. Since v5 it lives in the request namespace as request.security().
Broken code
TradingView reports the error on line 3.
//@version=6
indicator("Daily close", overlay = true)
dailyClose = security(syminfo.tickerid, "D", close)
plot(dailyClose)Fixed code
The same script, corrected for Pine Script v6. Paste it into the Pine Editor and save.
//@version=6
indicator("Daily close", overlay = true)
dailyClose = request.security(syminfo.tickerid, "D", close[1], lookahead = barmerge.lookahead_on)
plot(dailyClose, "Previous daily close", color.orange)Why it works
The arguments are the same: symbol, timeframe, expression. The fixed version also changes the request to the usual non-repainting form: close[1] with lookahead = barmerge.lookahead_on returns the last completed daily close on every bar, historical and live alike, so the line doesn't change after the fact. A plain request.security(syminfo.tickerid, "D", close) also compiles, but on the live bar it shows the daily close as it forms. More in how request.security works and repainting explained.
Other renamed request functions and variables
| v4 | v5 and v6 |
|---|---|
security() | request.security() |
financial() | request.financial() |
quandl() | request.quandl() |
tickerid | syminfo.tickerid |
period | timeframe.period |
The old variable names give Undeclared identifier "tickerid" and Undeclared identifier "period" rather than a "could not find function" message.
Questions
What is the v5 and v6 version of security()?
request.security(symbol, timeframe, expression). The arguments are the same as in v4; only the name moved into the request namespace.
Why does my request.security() line look different in real time?
Requesting the current higher-timeframe close shows a value that is still forming on the live bar, while historical bars show final values. Use close[1] with lookahead = barmerge.lookahead_on to get only completed values.
How many request.security() calls can a script make?
Up to 40 unique request.*() calls per script, or 64 with TradingView's Ultimate plan. Identical calls are reused rather than counted again.
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.