Could not find function or function reference 'security'
Call request.security() instead, and ask for the higher timeframe's last closed bar: close[1] with barmerge.lookahead_on.
Updated 23 October 2026. Runs in your browser; nothing you type is uploaded.
Try a worked example
My script, Pine v6 indicator
TradingView's compiler stops at line 3
Could not find function or function reference 'security'
Static checks, which read the code as written: Caution: 1 intrabar repaint pattern to verify. Edit the script and the compiler line goes; the checks below follow your edits.
Critical repaint flags
0
1 caution flag to verify
Bar-close gate
Not found
barstate.isconfirmed or a bar-close alert
Higher-timeframe calls
1
request.security() calls, of a 40 limit
Plots and alerts
1
Plots, of a 64 limit; 0 alerts
Repaint and lookahead
- Line 3: Unshifted higher-timeframe request.security() expressionCaution
Without a [1] offset on the requested expression, higher-timeframe values update on forming HTF bars during live trading.
Fix: For locked closed-bar levels, request expression[1] paired with lookahead = barmerge.lookahead_on.
Pine Script v6 migration checklist
These lines don't compile in v6, or behave differently. Check each one (TradingView's guide).
- Line 3: Unnamespaced security() callHigh risk
Pine Script v5 and v6 moved security() into the request.* namespace.
Fix: Replace security(...) with request.security(...).
The Pine Editor's error
Want TradingView indicators whose Pine Script v6 source already passes every check?
Every desk in Pine Pro Library ships as readable .pine v6 source with confirmed higher-timeframe requests and barstate.isconfirmed event logging.
What causes it
security() became request.security() in v5. Take the higher timeframe's previous bar with lookahead on, so it doesn't repaint.
The fix, compiled
Call request.security() instead, and ask for the higher timeframe's last closed bar: close[1] with barmerge.lookahead_on.
//@version=6
indicator("My script")
d = security(syminfo.tickerid, "D", close)
plot(d)//@version=6
indicator("My script")
d = request.security(syminfo.tickerid, "D", close[1], lookahead = barmerge.lookahead_on)
plot(d)Names Pine cannot find
- Could not find function or function reference 'study'
- Undeclared identifier "diff"
- Undeclared identifier "color.gold"
- Undeclared identifier "color.cyan"
- Could not find function or function reference 'iff'
- Could not find function or function reference 'ta.adx'
- Could not find function or function reference 'ta.sum'
- Could not find function or function reference 'ta.obv'
- Could not find function or function reference 'math.clamp'
- Could not find function or function reference 'dayofyear'
- Could not find function or function reference 'ema'
- Could not find function or function reference 'sma'
- Could not find function or function reference 'input.integer'
- Could not find function or function reference 'ta.kama'
- Could not find function or function reference 'ta.cmf'
- Could not find function or function reference 'ta.plus_di'
- Could not find function or function reference 'ta.slope'
- Could not find function or function reference 'ta.ichimoku'
- Could not find function or function reference 'ta.crossabove'
- Could not find function or function reference 'math.tanh'
- Could not find function or function reference 'math.mod'
- Could not find function or function reference 'input.timezone'
Compiled on TradingView 23 October 2026. The checker above reads repaint and v6 migration patterns; TradingView's compiler is the final word on whether a script compiles.
Have your AI fix the next one
- Pine Fixer An AI skill pack for 45 compiler-verified Pine v6 failure classes, with a repaint clinic. $9.99 once.