Skip to content
AlertaChartAlertaScript / docs
AlertaScript / alerta.request.security
On this pageSignatureParametersReturnsExampleNotes

Data requests / Reference

alerta.request.security

TradingView-compatible spelling: request.security, runs without warnings

Requests data from another symbol or timeframe and aligns it to the chart's bars. The expression is calculated on the requested bars: a higher-timeframe EMA is the EMA of the higher-timeframe bars, not an average of the chart's values. The symbol and the timeframe do not have to be literals — an input, a variable, a function result or a condition may supply them, so one script can request several symbols or timeframes, also from a loop. A symbol AlertaChart has no data for returns na with a warning naming it; the rest of the script keeps running, and the chart's own bars are never substituted for it.

alerta.request.security(symbol, timeframe, expression, gaps, lookahead) → series any

Parameters

NameTypeRequiredDefaultDescription
symbolstringYes—Ticker (e.g. "BINANCE:BTCUSDT", "NASDAQ:AAPL", an order-flow ticker such as "BINANCE:BTCUSDT.P_FUNDING"); syminfo.tickerid or "SELF" for the chart's own symbol.
timeframestringYes—Timeframe string (e.g. "D", "60", "240").
expressionanyYes—Expression to evaluate in that timeframe (e.g. close, sma(close, 20)). A tuple such as [close, time_close, time] returns one series per member.
gapsboolNo—Whether to return gaps (barmerge.gaps_on/off). Default false.
lookaheadboolNo—Whether to allow lookahead (barmerge.lookahead_on/off). lookahead_on reads the higher timeframe's finished bar, so the series can repaint on history — it runs, with a warning saying so (not for the non-repainting form, an expression offset by one).
currencystringNo—Read the requested symbol's prices in this currency (currency.EUR, "BTC", syminfo.currency …): open, high, low and close — and everything the expression builds from them — at the daily rate of the day before each bar; volume and literals stay as they are. Until the rate's data is loaded the request is na with a warning naming it.

Returns

series any

Example

alerta.request.security
indicator("Funding rate", overlay = false)// Order flow (Pro): Binance's BTC perpetual funding rate; any ticker works here ("ES1!", "NASDAQ:AAPL", …)sym = input.symbol("BINANCE:BTCUSDT.P_FUNDING", "Ticker")[rate, dailyRate] = request.security(sym, timeframe.period, [close, close * 3])plot(rate * 100, "Funding % per 8 h")plot(dailyRate * 100, "Funding % per day")

Notes

  • Tickers are answered from AlertaChart's own feeds: crypto venues (BINANCE, BYBIT, OKX, COINBASE, HYPERLIQUID, …), US stocks (NASDAQ:AAPL), forex (OANDA:EURUSD), indices (TVC:DXY, TVC:VIX, SP:SPX), US macro series (FRED:CPIAUCSL, TVC:US10Y), crypto market cap (CRYPTOCAP:TOTAL, BTC.D) and spread formulas (NASDAQ:AAPL/NASDAQ:MSFT). Symbols resolve with or without an exchange prefix when unique. Borsa Istanbul symbols are not available yet and return na with a warning; so do the closed stock markets and futures.
  • Stock, forex, futures and index tickers (and spreads with such a leg) come with the plans that open those charts (Trader and above); on other plans they return na, with a warning naming the plan. Crypto pairs, crypto market cap and US macro series are on every plan; order-flow tickers are Pro and Elite (below).
  • Spot gold and silver (OANDA:XAUUSD, TVC:GOLD, XAGUSD …) read the chart's own XAU/USD and XAG/USD on the plans that open those charts (Trader and above). On other plans the same tickers read Binance's XAUUSDT / XAGUSDT perpetual, and a warning names the plan the spot price comes with.
  • US macro series by their FRED id or TradingView name: Treasury yields (FRED:DGS10 or TVC:US10Y, US02Y, US05Y, GS20, US30Y, the 3-month bill FRED:DTB3), SOFR, the fed funds rate (FRED:DFF), the overnight reverse repo (FRED:RRPONTSYD), the 10Y–2Y and 10Y–3M spreads (FRED:T10Y2Y, FRED:T10Y3M) and the high-yield and corporate bond spreads (FRED:BAMLH0A0HYM2, FRED:BAMLC0A0CM) are daily: a request at an intraday timeframe reads the daily values. Release-based series such as CPI (FRED:CPIAUCSL), GDP or unemployment are monthly.
  • Order-flow data of crypto perpetuals is read the same way (Pro and Elite plans): EX:PAIR.P_OI open interest, EX:PAIR.P_FUNDING the funding rate (decimal per 8 hours, 0.0001 = 0.01 %), EX:PAIR.P_CVD cumulative volume delta in coins (EX:PAIR_CVD on spot; the bar's volume is its delta), EX:PAIR.P_LIQ_LONG / EX:PAIR.P_LIQ_SHORT the notional liquidated in the bar (USD) and EX:PAIR.P_NETLONG / EX:PAIR.P_NETSHORT net positions (coins), where EX is BINANCE, BYBIT, OKX, COINBASE or HYPERLIQUID — or AGG for every venue together (AGG:BTC.P_FUNDING, AGG:ETH.P_OI). Without the plan these tickers return na with a warning saying so. A venue's open interest is sampled every 5 minutes: on a 1- to 4-minute chart each value lands on the last chart bar of its 5-minute period, never ahead of the price.
  • Alignment follows Pine on historical bars: a request at the chart's own timeframe is the bar itself, and a higher-timeframe value (lookahead off) arrives on the chart bar that closes together with it — the last bar of its period. barmerge.lookahead_on reads the higher timeframe's finished bar and warns that the series can repaint; its non-repainting form, an expression offset by one (`close[1]` with lookahead_on), runs without that warning.
  • On the live (realtime) bar the request reads the higher timeframe's bar in progress, as Pine does — a daily close on an hourly chart is today's close so far, and barstate.isconfirmed inside the expression is false there. Such a value can change until its period closes (repaint); the non-repainting form `request.security(sym, tf, x[barstate.isrealtime ? 1 : 0])[barstate.isrealtime ? 0 : 1]` reads closed periods only.
  • Timeframe tokens follow Pine (1, 5, 60, 240, D, W, M; 1m, 1H, 1D; lowercase m = minutes, uppercase M = months).
  • A symbol or timeframe that changes from bar to bar — picked by a condition, read from an array of inputs, or walked by `for … in` — makes one request per value, each read where the call runs. A request inside an if block, a loop or a function is evaluated on the bars that reach it.
  • The expression may return a number, bool, string or color, a tuple such as [close, time_close, time] (destructured on assignment), an array, a matrix or a map (each chart bar gets it as it stood at the end of its requested bar) or an instance of a user-defined type. Before the first requested bar the value is na. A tuple is read only by taking it apart (`[a, b] = request.security(…)`); used as one value it is an error.
  • The variables the expression names are computed on the requested bars too, with the statements that write them — `var` sums, loops (their break and continue included), arrays and maps the script fills with push / put, and objects whose fields it writes.
  • Inside the expression, syminfo.*, timeframe.period and barstate.islast describe the requested symbol and bars; syminfo.main_tickerid and timeframe.main_period stay the chart's.
  • The expression — or a function it calls — may itself call request.security / request.economic (nested requests): the inner request runs in the outer one's context, its "" symbol and timeframe being the outer request's.
  • On a live chart another symbol's forming bar follows that symbol's own updates, so a spread or a comparison keeps moving with both markets.

Names and aliases

Guides and navigation are localized. Built-in reference descriptions and code examples are maintained in English.

AlertaScript

No results found.

Search by name, alias, or keyword.