Skip to content

request ​

How do you read another symbol or timeframe without looking ahead? Call request.security. It runs your expression on the other series and hands each value to the first chart bar that closes at or after the moment the value was known, so a historical bar never sees what it couldn't have seen then. The other functions on this page read published facts, funding rates and, in AmenoScript, a daily coin ranking or every member of a list at once.

pine
//@version=6
indicator("Last week's close, without looking ahead", overlay = true)
// The default: each week's close lands on the week's last daily bar,
// once the week has closed.
float thisWeek = request.security(syminfo.tickerid, "1W", close)
// TradingView's idiom: lookahead_on with an offset shows last week's close
// from the week's first bar.
float lastWeek = request.security(syminfo.tickerid, "1W", close[1],
      lookahead = barmerge.lookahead_on)
plot(thisWeek, "This week, once closed")
plot(lastWeek, "Last week, from Monday", color.orange)

request.security ​

pine
request.security(symbol, timeframe, expression, gaps, lookahead, ignore_invalid_symbol, currency, calc_bars_count, max_age) → series <type>

Runs an expression on another symbol or timeframe and returns each value on the first chart bar that could have known it.

A bar is known at its close, read from its symbol's calendar and exchange session, so SPY's daily bar is known at 16:00 New York time whatever time its bars are stamped. A daily value therefore reaches an hourly chart on the day's last hourly bar, and a weekly value reaches a daily chart on the week's last daily bar. A series with release dates, such as a macro print, a data pack or a CSV file, is known when each row was published, not at its period's end.

The expression runs on the other series' own bars, so ta.sma(close, 20) fills its window there. It can be anything a script can compute: a ta.* call, close[1], an input, your own function, or a tuple such as [open, close], which returns a tuple. Only the code that can change the expression's value runs in that context. Plots, drawings, alerts and orders inside it do nothing.

Closed chart bars see only closed bars of the other series. A chart bar that is still forming sees the other series' forming bar too, which is the one place a request can repaint.

Where this engine parts from TradingView:

  • A symbol it has no data for reads na and the run warns, where TradingView stops the script. The chart fetches the series the run reports missing, a symbol computed at run time included, and runs again.
  • currency converts nothing. The values stay in the symbol's own currency, and the run warns.
  • With gaps_on, if the other series' last bar closed before the chart's first bar opened, that first bar reads na here. TradingView may show the value there instead.

In leak-safe AmenoScript, which is how every AmenoScript text runs, a request can't look ahead. lookahead_on and calc_bars_count stop the script before it runs, and so does any read of a bar known after this bar's close. A series whose rows are later revisions rather than first prints reads na there. A Pine text gets warnings for the same things and runs as TradingView does.

ParameterDefaultDescription
symbol
series string
The series to read, for example "AAPL", "BTC-USD", "binance:BTC/USDT", "INDEX:BTCUSD" or "FRED:CPIAUCSL". An empty string means the chart's own symbol.
timeframe
series string
An empty string for the chart's own. Otherwise minutes as "60" or "240", hours as "4H", and "1D", "1W", "1M", or seconds as "30S".
expression
any
What to compute on that series.
gaps
simple barmerge_gaps
barmerge.gaps_offgaps_off holds the last value on bars that bring nothing new. gaps_on reads na except on the bar where a new value arrives.
lookahead
simple barmerge_lookahead
barmerge.lookahead_offlookahead_on shows a higher timeframe's bar from the first chart bar of its period, final value included. That reads the future unless the expression reads an earlier bar, as in close[1], and without such an offset the run warns. On a lower timeframe it reads the first intrabar. A series with release dates never looks ahead.
ignore_invalid_symbol
input bool
falsetrue keeps a missing series quiet. It reads na either way.
currencyNo effect here
series string
Accepted for compatibility. No conversion happens.
calc_bars_count
simple int
Runs the expression on only that series' last N bars.
max_ageAmenoScript only
simple int
Seconds. Once the value a bar would show became public more than this long before the bar's close, the read gives na, until the next value arrives. na means no limit. See known time.

request.security_lower_tf ​

pine
request.security_lower_tf(symbol, timeframe, expression, ignore_invalid_symbol, currency, ignore_invalid_timeframe, calc_bars_count) → array<type>

An array holding the expression's value on every intrabar of a lower timeframe inside this chart bar.

Each intrabar joins the array of the chart bar it closes in, by when it was known. A chart bar with no intrabars gets an empty array. A tuple expression returns a tuple of arrays. A timeframe higher than the chart's stops the script, unless ignore_invalid_timeframe is true, in which case the call reads na.

ParameterDefaultDescription
symbol
series string
The series to read, as for request.security.
timeframe
series string
A timeframe lower than the chart's, such as "60" on a daily chart.
expression
any
What to compute on each intrabar.
ignore_invalid_symbol
series bool
falsetrue keeps a missing series quiet. It reads an empty array either way.
currencyNo effect here
series string
Accepted for compatibility. No conversion happens.
ignore_invalid_timeframe
series bool
falsetrue reads na instead of stopping when the timeframe is higher than the chart's.
calc_bars_count
simple int
Runs the expression on only that series' last N bars. Refused in leak-safe AmenoScript.

request.dividends ​

pine
request.dividends(ticker, field, gaps, lookahead, ignore_invalid_symbol, currency) → series float

A dividend amount, read from the terminal's dividend series for the ticker, on the bar after its ex-date.

The value reaches the chart on the bar after the ex-date, as TradingView shows it. With lookahead_on it reads from the ex-date itself, and the run warns that this can be before the amount was public. Amounts stay as published.

ParameterDefaultDescription
ticker
series string
The share, such as "AAPL" or "NASDAQ:AAPL". An exchange prefix is dropped. Empty means the chart's symbol.
field
series string
dividends.grossdividends.gross. dividends.net reads the gross amount too, the only one the source gives, and the run warns.
gaps
simple barmerge_gaps
barmerge.gaps_offgaps_on reads na except on the bar a new amount arrives.
lookahead
simple barmerge_lookahead
barmerge.lookahead_offlookahead_on reads each amount from its own date. Refused in leak-safe AmenoScript.
ignore_invalid_symbol
input bool
falsetrue keeps a missing series quiet.
currencyNo effect here
series string
Accepted. Amounts aren't converted, and any currency but USD warns.

See facts.

request.splits ​

pine
request.splits(ticker, field, gaps, lookahead, ignore_invalid_symbol) → series float

One side of a share's latest split ratio, on the bar after its ex-date.

ParameterDefaultDescription
ticker
series string
The share. An exchange prefix is dropped. Empty means the chart's symbol.
field
series string
splits.numerator or splits.denominator. There is no default, and any other value reads na.
gaps
simple barmerge_gaps
barmerge.gaps_offgaps_on reads na except on the bar a new split arrives.
lookahead
simple barmerge_lookahead
barmerge.lookahead_offlookahead_on reads each split from its own date. Refused in leak-safe AmenoScript.
ignore_invalid_symbol
input bool
falsetrue keeps a missing series quiet.

See facts.

request.earnings ​

pine
request.earnings(ticker, field, gaps, lookahead, ignore_invalid_symbol, currency) → series float

A company's reported or estimated earnings per share, from the session after the report.

A report reaches the chart after the close on the next session, as TradingView shows it. With lookahead_on it reads from the report's own date, and the run warns.

ParameterDefaultDescription
ticker
series string
The share. An exchange prefix is dropped. Empty means the chart's symbol.
field
series string
earnings.actualearnings.actual or earnings.estimate. earnings.standardized reads the reported figure, the only one the source gives, and the run warns.
gaps
simple barmerge_gaps
barmerge.gaps_offgaps_on reads na except on the bar a new report arrives.
lookahead
simple barmerge_lookahead
barmerge.lookahead_offlookahead_on reads each report from its own date. Refused in leak-safe AmenoScript.
ignore_invalid_symbol
input bool
falsetrue keeps a missing series quiet.
currencyNo effect here
series string
Accepted. Figures aren't converted, and any currency but USD warns.

See facts.

request.economic ​

pine
request.economic(country_code, field, gaps, ignore_invalid_symbol) → series float

An economic series for a country, such as US CPI, from when each value was released.

US fields read public FRED series by TradingView's field codes, for example "CPI", "UR", "NFP", "GDP" and "M2". "INTR" gives the policy rate for the US and 16 other central banks, and a few other countries have "UR" and the euro area's inflation fields. Anything else reads na. A value reads at its release, and TradingView instead dates it at its period. That difference is on purpose: a backtest that dated a release at its period would hold each value weeks early.

ParameterDefaultDescription
country_code
series string
A two-letter code, such as "US", "GB" or "EU".
field
series string
The indicator's code, such as "CPI" or "INTR".
gaps
simple barmerge_gaps
barmerge.gaps_offgaps_on reads na except on the bar a new value arrives.
ignore_invalid_symbol
input bool
falsetrue keeps a missing series quiet.

See facts.

request.financial ​

pine
request.financial(symbol, financial_id, period, gaps, ignore_invalid_symbol, currency) → series float

A company's reported financial figure, such as revenue or total assets, from when its filing was public.

A quarter reads from its filing date. TradingView dates it at the quarter's last session, before anyone could know it, and this engine keeps the filing date on purpose.

ParameterDefaultDescription
symbol
series string
The share. An exchange prefix is dropped. Empty means the chart's symbol.
financial_id
series string
One of TOTAL_REVENUE, COST_OF_GOODS, GROSS_PROFIT, OPER_INCOME, NET_INCOME, SELL_GEN_ADMIN_EXP_TOTAL, RESEARCH_AND_DEV, EARNINGS_PER_SHARE_BASIC, EARNINGS_PER_SHARE_DILUTED, TOTAL_ASSETS, TOTAL_CURRENT_ASSETS, CASH_N_EQUIVALENTS, TOTAL_INVENTORY, ACCOUNTS_RECEIVABLES_NET, TOTAL_LIABILITIES, TOTAL_CURRENT_LIABILITIES, LONG_TERM_DEBT, SHORT_TERM_DEBT, TOTAL_EQUITY, TOTAL_SHARES_OUTSTANDING, CASH_F_OPERATING_ACTIVITIES, CAPITAL_EXPENDITURES or TOTAL_CASH_DIVIDENDS_PAID. Any other id reads na and the run warns.
period
series string
"FQ", "FY" or "TTM". "FH" reads na, since US filers don't report half years.
gaps
simple barmerge_gaps
barmerge.gaps_offgaps_on reads na except on the bar a new figure arrives.
ignore_invalid_symbol
input bool
falsetrue keeps a missing series quiet.
currencyNo effect here
series string
Accepted. Figures aren't converted, and any currency but USD warns.

See facts.

request.funding ​

AmenoScript only
ameno
request.funding(coin, venue, series) → series float

A perpetual future's funding for a coin on an exchange, as an annual percentage or as the raw rate.

The series runs at the chart's timeframe, and a bar's last settlement is known when that bar closes. It reads the terminal's FUND:<venue>:<coin> series, so a chart of that symbol shows the same numbers.

ParameterDefaultDescription
coin
series string
The coin, such as "BTC".
venue
simple string
"binance""binance", "bybit", "hyperliquid" (or "hl"), "gate" or "bitget".
series
simple string
"apr""apr" for the annualised percentage, or "rate" for the rate each settlement paid.

See funding.

request.currency_rate ​

pine
request.currency_rate(from, to, ignore_invalid_currency) → series float

The rate from one currency to another: 1 when both are the same, and na with a warning otherwise, since no exchange rates are loaded.

ParameterDefaultDescription
from
series string
The currency to convert from, such as "EUR".
to
series string
The currency to convert to.
ignore_invalid_currencyNo effect here
series bool
falseAccepted. The call reads na for two different currencies either way.

request.seed ​

Pine v6No effect here
pine
request.seed(source, symbol, expression, ignore_invalid_symbol, calc_bars_count) → series <type>

Always na: this engine has no seed repositories.

ParameterDefaultDescription
source
series string
The repository name.
symbol
series string
The series within it.
expression
<arg_expr_type>
What to compute.
ignore_invalid_symbol
input bool
falseAccepted.
calc_bars_count
simple int
Accepted.

request.quandl ​

Pine v6No effect here
pine
request.quandl(ticker, gaps, index, ignore_invalid_symbol) → series float

Always na: this engine reads no Nasdaq Data Link series.

ParameterDefaultDescription
ticker
series string
The series name.
gaps
simple barmerge_gaps
barmerge.gaps_offAccepted.
index
series int
The column.
ignore_invalid_symbol
input bool
falseAccepted.

request.footprint ​

Pine v6No effect here
pine
request.footprint(ticks_per_row) → series footprint

Always na: this engine builds no volume footprints, and the footprint.* and volume_row.* functions read na too.

ParameterDescription
ticks_per_row
simple int
The rows' height, in ticks.

request.md ​

AmenoScript onlyNo effect here
ameno
request.md(ticker, field, gaps, ignore_invalid_symbol) → series float

Reserved: no data is behind it yet, so it always returns na. The engine accepts the name so that a script that calls it still runs.

ParameterDefaultDescription
ticker
series string
The symbol.
field
series string
The field.
gaps
simple barmerge_gaps
barmerge.gaps_offAccepted.
ignore_invalid_symbol
simple bool
falseAccepted.

request.universe ​

AmenoScript only
ameno
request.universe(top, exclude_tags, include_tags, min_mcap, min_volume, min_age_days, hindsight) → array<string>

CoinMarketCap's ranking as an array of CMC: symbols, best rank first, for the last date known by this bar's close.

A date is known when it ends, so date D is known at the next midnight UTC. A daily chart's bar for D reads date D, and a bar still forming reads the day before. Before the first stored date the array is empty. Pass a member to request.security or request.each to read its price. Each filter reads that date's own values, so an old date has few tags: in 2017, USDT has none.

ameno
indicator("Share of the top 20 above their 50-day average")
array<string> m = request.universe(20, "stablecoin")
array<float> above = request.each(m, close > ta.sma(close, 50) ? 1.0 : 0.0)
plot(array.avg(above), "Share above") // na cells are skipped
ParameterDefaultDescription
top
simple int
50How many to keep, counted after the other filters.
exclude_tags
simple string
Comma-separated tags. A coin holding any of them on that date is left out.
include_tags
simple string
Comma-separated tags. Only a coin holding one of them on that date is kept.
min_mcap
simple float
The least market cap in US dollars on that date.
min_volume
simple float
The least 24-hour volume in US dollars on that date.
min_age_days
simple int
The least days since CoinMarketCap first listed the coin.
hindsight
simple bool
falsetrue reads each coin's newest tags on every date, which nobody had then. Leak-safe AmenoScript refuses it, and any other run warns.

See the universe, and its date rule.

request.each ​

AmenoScript only
ameno
request.each(members, expression, gaps) → array<type>

Runs an expression on each member of a list of symbols and returns the results as an array in the list's order.

Each member runs as request.security would run it: on its own bars, with its own ta.* state and history, read at what this bar may see. A tuple expression returns one array per element. A member with no data reads na and is fetched for the next run. Call it at the top level of the script, not inside a function, a block or another request.

x[k] on the array that comes back is refused, because positions move when members move. Take the past inside the expression instead: request.each(m, close[5]).

ParameterDefaultDescription
members
array<string>
An array<string> of symbols, such as request.universe(50).
expression
any
What to compute on each member.
gaps
simple barmerge_gaps
barmerge.gaps_offgaps_on reads na on a bar with no new print.

See each and pairs.

request.pairs ​

AmenoScript only
ameno
request.pairs(members, expression, warm) → matrix<type>

Runs an expression on every ordered pair of members, on the ratio of their closes, and returns a matrix.

Row i, column j holds the expression run on member i over member j. Inside the expression, close is the ratio of the two closes, left and right are the two closes themselves, and close[k], left[k] and right[k] read the pair's own past. A pair has no open, high, low or volume, so reading one, or calling a ta.* that reads them unasked, such as ta.atr, is refused. So are request.*, syminfo.* and a strategy() inside it. The diagonal is na, a zero on the right reads na, and a tuple expression returns one matrix per element.

A pair steps on the bars either coin printed, from the first day both have a price, and holds a coin's last close on a day it didn't print. It reads closed bars only. Up to 12,000 pairs keep their state, and a pair dropped past that replays to the same values when read again.

ParameterDefaultDescription
members
array<string>
An array<string> of symbols.
expression
any
What to compute on each pair.
warm
simple bool
truetrue starts a pair at the two coins' first shared price whenever it is first read, so a coin joins the list with its past. false starts it on the bar it is first read.

See each and pairs.

request.age ​

AmenoScript only
ameno
request.age(symbol, timeframe) → series int

How many seconds before this bar's close the value this bar can read became public, as an int.

It reads na before the first value and when nothing loaded, and it is never negative. The chart's own series reads 0.

ParameterDescription
symbol
series string
The series, as for request.security. Empty means the chart's symbol.
timeframe
series string
Its timeframe. Empty means the chart's.

See known time.

request.status ​

AmenoScript only
ameno
request.status(symbol, timeframe) → series string

Whether a series has a current value to read: "ok", "late", "waiting" or "failed".

"ok" means there is a value to read, a quiet day between values included. "late" means the next value is overdue: 40 days on a monthly macro series, 6 days on a stock, 2.5 bars on a coin, and 5 times the median spacing so far on a file or funding series. A rank series is never late. "waiting" means the series loaded but nothing in it is public yet, and "failed" means nothing loaded. A symbol only the run can name reads "failed" until the chart has fetched it and run again. The chart's own series reads "ok".

ParameterDescription
symbol
series string
The series. Empty means the chart's symbol.
timeframe
series string
Its timeframe. Empty means the chart's.

request.quality ​

AmenoScript only
ameno
request.quality(symbol, timeframe) → series string

The data-quality flag on the value this bar can read: "bad", "gap", "jump" or "partial", the worst if it has several, and "" when it has none.

Each flag rests only on the bars up to its own, so it can't look ahead. It also reads "" when there is nothing to read, which request.status tells apart. Leak-safe AmenoScript takes no run on a forming bar, so there it never reads "partial".

ParameterDescription
symbol
series string
The series. Empty means the chart's symbol.
timeframe
series string
Its timeframe. Empty means the chart's.

barmerge.gaps_off ​

pine
const barmerge_gaps barmerge.gaps_off

The default for gaps: a request holds its last value on bars that bring nothing new.

barmerge.gaps_on ​

pine
const barmerge_gaps barmerge.gaps_on

For gaps: a request reads na except on the bar where a new value arrives.

barmerge.lookahead_off ​

pine
const barmerge_lookahead barmerge.lookahead_off

The default for lookahead: a value shows on the first chart bar closing at or after it was known.

barmerge.lookahead_on ​

pine
const barmerge_lookahead barmerge.lookahead_on

For lookahead: a higher timeframe's bar shows from the first chart bar of its period. Pair it with an offset such as close[1]. Leak-safe AmenoScript refuses it.

ticker.new ​

pine
ticker.new(prefix, ticker, session, adjustment, backadjustment, settlement_as_close) → simple string

Builds a ticker string from a prefix and a symbol. An adjustment other than none names the adjusted view of a share's bars, which request.security reads.

ParameterDefaultDescription
prefix
simple string
The exchange, such as "NASDAQ". An empty string leaves the symbol bare.
ticker
simple string
The symbol.
sessionNo effect here
simple string
session.regularAccepted. The session doesn't change what is read.
adjustment
simple string
adjustment.noneadjustment.splits or adjustment.dividends reads the share's adjusted bars.
backadjustmentNo effect here
simple backadjustment
backadjustment.inheritAccepted, and changes nothing.
settlement_as_closeNo effect here
simple settlement
settlement_as_close.inheritAccepted, and changes nothing.

ticker.modify ​

pine
ticker.modify(tickerid, session, adjustment, backadjustment, settlement_as_close) → simple string

A ticker with a new adjustment, keeping its symbol.

ParameterDefaultDescription
tickerid
simple string
The ticker to change.
sessionNo effect here
simple string
session.regularAccepted. The session doesn't change what is read.
adjustment
simple string
adjustment.noneadjustment.splits, adjustment.dividends or adjustment.none. Left out, the ticker keeps its own.
backadjustmentNo effect here
simple backadjustment
backadjustment.inheritAccepted, and changes nothing.
settlement_as_closeNo effect here
simple settlement
settlement_as_close.inheritAccepted, and changes nothing.

ticker.standard ​

pine
string ticker.standard
ticker.standard(symbol) → simple string

The ticker unchanged.

ParameterDescription
symbol
simple string
The ticker.

ticker.inherit ​

pine
ticker.inherit(from_tickerid, symbol) → simple string

The ticker symbol, with the adjustment and chart type that from_tickerid carries.

ParameterDescription
from_tickerid
simple string
The ticker whose modifiers to copy.
symbol
simple string
The symbol to give them to. Left out, the call returns from_tickerid.

ticker.heikinashi ​

Pine v6No effect here
pine
ticker.heikinashi(symbol) → simple string

The ticker with a Heikin Ashi suffix. No such series is loaded, so a request on it reads na and warns.

ParameterDescription
symbol
simple string
The ticker.

ticker.kagi ​

Pine v6No effect here
pine
ticker.kagi(symbol, reversal) → simple string

The ticker with a Kagi suffix. No such series is loaded, so a request on it reads na.

ParameterDescription
symbol
simple string
The ticker.
reversal
simple int/float
Accepted.

ticker.linebreak ​

Pine v6No effect here
pine
ticker.linebreak(symbol, number_of_lines) → simple string

The ticker with a line break suffix. No such series is loaded, so a request on it reads na.

ParameterDescription
symbol
simple string
The ticker.
number_of_lines
simple int
Accepted.

ticker.pointfigure ​

Pine v6No effect here
pine
ticker.pointfigure(symbol, source, style, param, reversal) → simple string

The ticker with a point and figure suffix. No such series is loaded, so a request on it reads na.

ParameterDescription
symbol
simple string
The ticker.
source
simple string
Accepted.
style
simple string
Accepted.
param
simple int/float
Accepted.
reversal
simple int
Accepted.

ticker.renko ​

Pine v6No effect here
pine
ticker.renko(symbol, style, param, request_wicks, source) → simple string

The ticker with a Renko suffix. No such series is loaded, so a request on it reads na.

ParameterDefaultDescription
symbol
simple string
The ticker.
style
simple string
Accepted.
param
simple float
Accepted.
request_wicks
simple bool
falseAccepted.
source
simple string
"close"Accepted.

adjustment.* ​

Values for ticker.new and ticker.modify's adjustment. adjustment.splits and adjustment.dividends read a share's bars adjusted back for splits, or for splits and dividends. adjustment.none reads the plain bars.

Each is a const string.

backadjustment.* ​

No effect here

Values for ticker.new and ticker.modify's backadjustment, accepted for compatibility with TradingView's continuous futures. They change nothing here.

Each is a const backadjustment.

settlement_as_close.* ​

No effect here

Values for ticker.new and ticker.modify's settlement_as_close, accepted for compatibility with TradingView's futures. They change nothing here.

Each is a const settlement.

close.* ​

AmenoScript onlyNo effect here

Three values that TradingView doesn't have and nothing in this engine reads. For a futures symbol's settlement price, TradingView's setting is settlement_as_close.*, which this engine accepts and ignores too.

Each is a string.

dividends.* ​

Fields for request.dividends. dividends.gross is the amount before tax, and dividends.net reads the gross amount too. The dividends.future_* values read na, since no feed here holds a date still to come.

NameType
dividends.future_amountseries float
dividends.future_ex_dateseries float
dividends.future_pay_dateseries float
dividends.grossconst string
dividends.netconst string

earnings.* ​

Fields for request.earnings. earnings.actual is the reported figure and earnings.estimate the consensus, while earnings.standardized reads the reported figure. The earnings.future_* values read na, since no feed here holds a date still to come.

splits.* ​

Fields for request.splits: splits.numerator and splits.denominator, the two sides of a split's ratio.

Each is a const string.

AmenoScript is compatible with Pine Script v6. Pine Script is a trademark of TradingView, Inc., which has no part in AmenoScript.