Why does request.security() return an error or na in Pine Script?

Market Data · Pine Script
SOURCE-CHECKED FIX Source checked Aug 12, 2026 TradingView documentation ✓
Short answer

Verify the requested symbol, timeframe and expression first. Then inspect gaps, unavailable history, invalid-context handling and dynamic request behavior before treating na as a platform failure.

What you may be seeing

  • request.security() returns na on some or all bars
  • The script raises an invalid symbol, timeframe or request error
  • Results differ after changing the chart symbol or timeframe

Most likely causes

  1. The requested symbol or timeframe is invalid or lacks data
  2. Gap mapping legitimately returns na where no requested bar exists
  3. The expression or dynamic request creates an unsupported or excessive context

Try this first

  1. Test the exact ticker ID and timeframe with a simple close expression
  2. Confirm that the requested market has data for the relevant dates
  3. Review gaps and lookahead settings for the intended mapping
  4. Handle expected na values and invalid contexts explicitly

If that didn’t fix it

  1. Use ticker.new() or ticker.modify() to construct the intended context
  2. Request a small tuple of required values once instead of many separate calls
  3. Use request.security_lower_tf() when arrays of lower-timeframe intrabars are required

Verify the fix

A minimal request returns expected values on known bars, and the production script handles legitimate missing data without false signals.

Why this happens

Verify the requested symbol, timeframe and expression first. Then inspect gaps, unavailable history, invalid-context handling and dynamic request behavior before treating na as a platform failure.

request.security() evaluates an expression in another context and maps the result back to chart bars. Missing source bars, an invalid symbol or timeframe, an unsupported request pattern, or deliberate gap behavior can all produce an error or na.

Sources & next steps

Did this fix your problem? Your answer helps us rank fixes by real-world usefulness.
← Back to Resolve