Skip to content

request namespace

The request namespace covers every API that imports data from outside the script’s native series. Common uses include higher-timeframe OHLC values, fundamentals (earnings, dividends, financial statements), or macroeconomic datasets. Each function executes in the script’s calculation context, so the results align with Pine’s bar-by-bar execution model.

A script can contain at most 40 unique `request.*()` calls. Beyond that limit Pine throws a runtime error. Reuse helper functions and avoid constructing unique argument combinations unnecessarily.

FunctionPurpose
request.security(symbol, timeframe, expression, ignore_invalid_symbol, currency, ignore_invalid_timeframe, calc_bars_count)Evaluate expression in another symbol/timeframe and return the result.
request.security_lower_tf(symbol, timeframe, expression, ...)Retrieve lower-timeframe data as an array for intrabar modelling.
request.financial(symbol, financial_id, period, ...)Access financial statement line items.
request.dividends(symbol, field, ...) / request.earnings(symbol, field, ...) / request.splits(symbol, field, ...)Pull corporate action series.
request.economic(country_code, field, ...)Load macroeconomic indicators.
  • symbol / ticker — Pass syminfo.tickerid or a prefixed string like "NASDAQ:AAPL". To request extended or adjusted data, build a custom ticker with the ticker.* helpers.
  • timeframe — Use an empty string ("") or timeframe.period to inherit the chart. Supply custom strings like "15" or "240" for minutes, "D" for daily, etc.
  • gaps / lookahead — Control how data aligns with the host series. barmerge.gaps_on retains na gaps; barmerge.lookahead_off prevents future leaks and is default.
  • ignore_invalid_symbol/timeframe/currency — When true, the call returns na instead of throwing an error if the resource is unavailable.
  • calc_bars_count — Limit how many historical bars Pine loads for performance-sensitive requests.
  • Requests execute synchronously inside bar processing. Heavy chains of request.security() can slow scripts, so lean on inputs (calc_bars_count, ignore_invalid_timeframe) to keep workloads focused.
  • Avoid barstate.isconfirmed or other runtime-only variables inside request.security() expressions because they refer to the requested context, not the main chart.
  • Currency conversion applies only to price-like series. Literal constants are unaffected.
//@version=5
indicator("Higher timeframe trend with fundamentals", overlay=false)
symbol = input.symbol(syminfo.tickerid, "Symbol")
htf = input.timeframe("D", "Reference timeframe")
htfClose = request.security(symbol, htf, close)
ttmEps = request.financial(symbol, "NET_INCOME", "TTM", gaps=barmerge.gaps_on)
plot(htfClose, "Daily close", color=color.teal)
plot(ta.sma(htfClose, 20), "HTF SMA", color=color.orange)
if barstate.islastconfirmedhistory
label.new(bar_index, htfClose,
text = "TTM net income: " + str.tostring(ttmEps, "#.##"),
textcolor=color.white,
bgcolor=color.new(color.blue, 75),
style=label.style_label_left)