request namespace
request
Section titled “request”Overview
Section titled “Overview”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.
Common helpers
Section titled “Common helpers”| Function | Purpose |
|---|---|
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. |
Parameters (shared concepts)
Section titled “Parameters (shared concepts)”- symbol / ticker — Pass
syminfo.tickeridor a prefixed string like"NASDAQ:AAPL". To request extended or adjusted data, build a custom ticker with theticker.*helpers. - timeframe — Use an empty string (
"") ortimeframe.periodto 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_onretainsnagaps;barmerge.lookahead_offprevents future leaks and is default. - ignore_invalid_symbol/timeframe/currency — When
true, the call returnsnainstead of throwing an error if the resource is unavailable. - calc_bars_count — Limit how many historical bars Pine loads for performance-sensitive requests.
Remarks
Section titled “Remarks”- 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.isconfirmedor other runtime-only variables insiderequest.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.
Example
Section titled “Example”//@version=5indicator("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)