Appearance
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
naand 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. currencyconverts 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 readsnahere. 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.
| Parameter | Default | Description |
|---|---|---|
symbolseries 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. | |
timeframeseries 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". | |
expressionany | What to compute on that series. | |
gapssimple barmerge_gaps | barmerge.gaps_off | gaps_off holds the last value on bars that bring nothing new. gaps_on reads na except on the bar where a new value arrives. |
lookaheadsimple barmerge_lookahead | barmerge.lookahead_off | lookahead_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_symbolinput bool | false | true keeps a missing series quiet. It reads na either way. |
currencyNo effect hereseries string | Accepted for compatibility. No conversion happens. | |
calc_bars_countsimple int | Runs the expression on only that series' last N bars. | |
max_ageAmenoScript onlysimple 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.
| Parameter | Default | Description |
|---|---|---|
symbolseries string | The series to read, as for request.security. | |
timeframeseries string | A timeframe lower than the chart's, such as "60" on a daily chart. | |
expressionany | What to compute on each intrabar. | |
ignore_invalid_symbolseries bool | false | true keeps a missing series quiet. It reads an empty array either way. |
currencyNo effect hereseries string | Accepted for compatibility. No conversion happens. | |
ignore_invalid_timeframeseries bool | false | true reads na instead of stopping when the timeframe is higher than the chart's. |
calc_bars_countsimple 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 floatA 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.
| Parameter | Default | Description |
|---|---|---|
tickerseries string | The share, such as "AAPL" or "NASDAQ:AAPL". An exchange prefix is dropped. Empty means the chart's symbol. | |
fieldseries string | dividends.gross | dividends.gross. dividends.net reads the gross amount too, the only one the source gives, and the run warns. |
gapssimple barmerge_gaps | barmerge.gaps_off | gaps_on reads na except on the bar a new amount arrives. |
lookaheadsimple barmerge_lookahead | barmerge.lookahead_off | lookahead_on reads each amount from its own date. Refused in leak-safe AmenoScript. |
ignore_invalid_symbolinput bool | false | true keeps a missing series quiet. |
currencyNo effect hereseries 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 floatOne side of a share's latest split ratio, on the bar after its ex-date.
| Parameter | Default | Description |
|---|---|---|
tickerseries string | The share. An exchange prefix is dropped. Empty means the chart's symbol. | |
fieldseries string | splits.numerator or splits.denominator. There is no default, and any other value reads na. | |
gapssimple barmerge_gaps | barmerge.gaps_off | gaps_on reads na except on the bar a new split arrives. |
lookaheadsimple barmerge_lookahead | barmerge.lookahead_off | lookahead_on reads each split from its own date. Refused in leak-safe AmenoScript. |
ignore_invalid_symbolinput bool | false | true keeps a missing series quiet. |
See facts.
request.earnings
pine
request.earnings(ticker, field, gaps, lookahead, ignore_invalid_symbol, currency) → series floatA 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.
| Parameter | Default | Description |
|---|---|---|
tickerseries string | The share. An exchange prefix is dropped. Empty means the chart's symbol. | |
fieldseries string | earnings.actual | earnings.actual or earnings.estimate. earnings.standardized reads the reported figure, the only one the source gives, and the run warns. |
gapssimple barmerge_gaps | barmerge.gaps_off | gaps_on reads na except on the bar a new report arrives. |
lookaheadsimple barmerge_lookahead | barmerge.lookahead_off | lookahead_on reads each report from its own date. Refused in leak-safe AmenoScript. |
ignore_invalid_symbolinput bool | false | true keeps a missing series quiet. |
currencyNo effect hereseries 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 floatAn 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.
| Parameter | Default | Description |
|---|---|---|
country_codeseries string | A two-letter code, such as "US", "GB" or "EU". | |
fieldseries string | The indicator's code, such as "CPI" or "INTR". | |
gapssimple barmerge_gaps | barmerge.gaps_off | gaps_on reads na except on the bar a new value arrives. |
ignore_invalid_symbolinput bool | false | true keeps a missing series quiet. |
See facts.
request.financial
pine
request.financial(symbol, financial_id, period, gaps, ignore_invalid_symbol, currency) → series floatA 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.
| Parameter | Default | Description |
|---|---|---|
symbolseries string | The share. An exchange prefix is dropped. Empty means the chart's symbol. | |
financial_idseries 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. | |
periodseries string | "FQ", "FY" or "TTM". "FH" reads na, since US filers don't report half years. | |
gapssimple barmerge_gaps | barmerge.gaps_off | gaps_on reads na except on the bar a new figure arrives. |
ignore_invalid_symbolinput bool | false | true keeps a missing series quiet. |
currencyNo effect hereseries 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 floatA 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.
| Parameter | Default | Description |
|---|---|---|
coinseries string | The coin, such as "BTC". | |
venuesimple string | "binance" | "binance", "bybit", "hyperliquid" (or "hl"), "gate" or "bitget". |
seriessimple 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 floatThe rate from one currency to another: 1 when both are the same, and na with a warning otherwise, since no exchange rates are loaded.
| Parameter | Default | Description |
|---|---|---|
fromseries string | The currency to convert from, such as "EUR". | |
toseries string | The currency to convert to. | |
ignore_invalid_currencyNo effect hereseries bool | false | Accepted. 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.
| Parameter | Default | Description |
|---|---|---|
sourceseries string | The repository name. | |
symbolseries string | The series within it. | |
expression<arg_expr_type> | What to compute. | |
ignore_invalid_symbolinput bool | false | Accepted. |
calc_bars_countsimple int | Accepted. |
request.quandl
Pine v6No effect here
pine
request.quandl(ticker, gaps, index, ignore_invalid_symbol) → series floatAlways na: this engine reads no Nasdaq Data Link series.
| Parameter | Default | Description |
|---|---|---|
tickerseries string | The series name. | |
gapssimple barmerge_gaps | barmerge.gaps_off | Accepted. |
indexseries int | The column. | |
ignore_invalid_symbolinput bool | false | Accepted. |
request.footprint
Pine v6No effect here
pine
request.footprint(ticks_per_row) → series footprintAlways na: this engine builds no volume footprints, and the footprint.* and volume_row.* functions read na too.
| Parameter | Description |
|---|---|
ticks_per_rowsimple int | The rows' height, in ticks. |
request.md
AmenoScript onlyNo effect here
ameno
request.md(ticker, field, gaps, ignore_invalid_symbol) → series floatReserved: 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.
| Parameter | Default | Description |
|---|---|---|
tickerseries string | The symbol. | |
fieldseries string | The field. | |
gapssimple barmerge_gaps | barmerge.gaps_off | Accepted. |
ignore_invalid_symbolsimple bool | false | Accepted. |
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| Parameter | Default | Description |
|---|---|---|
topsimple int | 50 | How many to keep, counted after the other filters. |
exclude_tagssimple string | Comma-separated tags. A coin holding any of them on that date is left out. | |
include_tagssimple string | Comma-separated tags. Only a coin holding one of them on that date is kept. | |
min_mcapsimple float | The least market cap in US dollars on that date. | |
min_volumesimple float | The least 24-hour volume in US dollars on that date. | |
min_age_dayssimple int | The least days since CoinMarketCap first listed the coin. | |
hindsightsimple bool | false | true 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]).
| Parameter | Default | Description |
|---|---|---|
membersarray<string> | An array<string> of symbols, such as request.universe(50). | |
expressionany | What to compute on each member. | |
gapssimple barmerge_gaps | barmerge.gaps_off | gaps_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.
| Parameter | Default | Description |
|---|---|---|
membersarray<string> | An array<string> of symbols. | |
expressionany | What to compute on each pair. | |
warmsimple bool | true | true 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 intHow 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.
| Parameter | Description |
|---|---|
symbolseries string | The series, as for request.security. Empty means the chart's symbol. |
timeframeseries string | Its timeframe. Empty means the chart's. |
See known time.
request.status
AmenoScript only
ameno
request.status(symbol, timeframe) → series stringWhether 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".
| Parameter | Description |
|---|---|
symbolseries string | The series. Empty means the chart's symbol. |
timeframeseries string | Its timeframe. Empty means the chart's. |
request.quality
AmenoScript only
ameno
request.quality(symbol, timeframe) → series stringThe 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".
| Parameter | Description |
|---|---|
symbolseries string | The series. Empty means the chart's symbol. |
timeframeseries string | Its timeframe. Empty means the chart's. |
barmerge.gaps_off
pine
const barmerge_gaps barmerge.gaps_offThe default for gaps: a request holds its last value on bars that bring nothing new.
barmerge.gaps_on
pine
const barmerge_gaps barmerge.gaps_onFor gaps: a request reads na except on the bar where a new value arrives.
barmerge.lookahead_off
pine
const barmerge_lookahead barmerge.lookahead_offThe 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_onFor 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 stringBuilds 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.
| Parameter | Default | Description |
|---|---|---|
prefixsimple string | The exchange, such as "NASDAQ". An empty string leaves the symbol bare. | |
tickersimple string | The symbol. | |
sessionNo effect heresimple string | session.regular | Accepted. The session doesn't change what is read. |
adjustmentsimple string | adjustment.none | adjustment.splits or adjustment.dividends reads the share's adjusted bars. |
backadjustmentNo effect heresimple backadjustment | backadjustment.inherit | Accepted, and changes nothing. |
settlement_as_closeNo effect heresimple settlement | settlement_as_close.inherit | Accepted, and changes nothing. |
ticker.modify
pine
ticker.modify(tickerid, session, adjustment, backadjustment, settlement_as_close) → simple stringA ticker with a new adjustment, keeping its symbol.
| Parameter | Default | Description |
|---|---|---|
tickeridsimple string | The ticker to change. | |
sessionNo effect heresimple string | session.regular | Accepted. The session doesn't change what is read. |
adjustmentsimple string | adjustment.none | adjustment.splits, adjustment.dividends or adjustment.none. Left out, the ticker keeps its own. |
backadjustmentNo effect heresimple backadjustment | backadjustment.inherit | Accepted, and changes nothing. |
settlement_as_closeNo effect heresimple settlement | settlement_as_close.inherit | Accepted, and changes nothing. |
ticker.standard
pine
string ticker.standard
ticker.standard(symbol) → simple stringThe ticker unchanged.
| Parameter | Description |
|---|---|
symbolsimple string | The ticker. |
ticker.inherit
pine
ticker.inherit(from_tickerid, symbol) → simple stringThe ticker symbol, with the adjustment and chart type that from_tickerid carries.
| Parameter | Description |
|---|---|
from_tickeridsimple string | The ticker whose modifiers to copy. |
symbolsimple 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 stringThe ticker with a Heikin Ashi suffix. No such series is loaded, so a request on it reads na and warns.
| Parameter | Description |
|---|---|
symbolsimple string | The ticker. |
ticker.kagi
Pine v6No effect here
pine
ticker.kagi(symbol, reversal) → simple stringThe ticker with a Kagi suffix. No such series is loaded, so a request on it reads na.
| Parameter | Description |
|---|---|
symbolsimple string | The ticker. |
reversalsimple int/float | Accepted. |
ticker.linebreak
Pine v6No effect here
pine
ticker.linebreak(symbol, number_of_lines) → simple stringThe ticker with a line break suffix. No such series is loaded, so a request on it reads na.
| Parameter | Description |
|---|---|
symbolsimple string | The ticker. |
number_of_linessimple int | Accepted. |
ticker.pointfigure
Pine v6No effect here
pine
ticker.pointfigure(symbol, source, style, param, reversal) → simple stringThe ticker with a point and figure suffix. No such series is loaded, so a request on it reads na.
| Parameter | Description |
|---|---|
symbolsimple string | The ticker. |
sourcesimple string | Accepted. |
stylesimple string | Accepted. |
paramsimple int/float | Accepted. |
reversalsimple int | Accepted. |
ticker.renko
Pine v6No effect here
pine
ticker.renko(symbol, style, param, request_wicks, source) → simple stringThe ticker with a Renko suffix. No such series is loaded, so a request on it reads na.
| Parameter | Default | Description |
|---|---|---|
symbolsimple string | The ticker. | |
stylesimple string | Accepted. | |
paramsimple float | Accepted. | |
request_wickssimple bool | false | Accepted. |
sourcesimple 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.
| Name | Type |
|---|---|
dividends. | series float |
dividends. | series float |
dividends. | series float |
dividends. | const string |
dividends. | const 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.
| Name | Type |
|---|---|
earnings. | const string |
earnings. | const string |
earnings. | series float |
earnings. | series float |
earnings. | series float |
earnings. | series float |
earnings. | const string |
splits.*
Fields for request.splits: splits.numerator and splits.denominator, the two sides of a split's ratio.
Each is a const string.