CODESCRIPT

Multi-timeframe

24 entries. What each one takes, what it returns, and a working example.

currencyRate(source, target)

Exchange-rate series (from==to → 1, no data needed). Supported units: USD, EUR, GBP, JPY, TRY, AUD, CAD, CHF, NZD and XAU/XAG (gold/silver ounce). If the direct pair is unavailable the inverse (1/rate) is used, and failing that a USD cross is computed — so every combination of these 11 units works. The value is the rate at that bar's close; na before the rate data begins (no rate is carried back into the past). Source/target must be LITERAL text: a variable call like `currencyRate(a, b)` returns na. Keyword-argument names: `source`/`target` (canonical). `from`/`to` and `kaynak`/`hedef` do the same thing.

Returns the exchange-rate series between two currencies. 1.0 if source = target; na if unavailable.

source
string
Source currency (e.g. "EUR").
target
string
Target currency (e.g. "USD").

Note

For converting values in different currencies to a comparable unit. Rate data comes from the terminal. If the direct pair is unavailable the inverse (1/rate) is used, and failing that a USD cross is computed — every combination of the 11 supported units works.

When to use

To align two values priced in different currencies to a common unit before comparing them.

Limits

Supported units: USD, EUR, GBP, JPY, TRY, AUD, CAD, CHF, NZD and XAU/XAG (gold/silver ounce) — any other code returns na. Source/target must be LITERAL text: a variable call like `currencyRate(a, b)` fetches no rate and returns na. na before the bar where rate data begins (no rate is carried back into the past). If the same currency code is given, the result is a constant 1.0 (no data needed). Codes are case-insensitive.

Not for

Not for converting a strategy's P&L to the account currency (that is convertToAccount's job); nor is it a price feed.

For converting values in different currencies to a comparable unit. Rate data would come from the terminal once connected; currently not connected (see limits).

CODESCRIPT
plot(currencyRate("EUR", "USD"), "EURUSD Rate")

Currently always na (empty line) — no data source connected yet.

CODESCRIPT
plot(currencyRate("USD", "USD"), "Same currency")

Plots a constant 1.0 because the same currency is given.

dividends(symbol, field?)

Dividend series. Fields: "gross", "net" (after withholding), "yield" (%), "paid" (total paid). For BIST stocks, gross and net are read from the per-1-TL-nominal amounts in Borsa İstanbul's rights-usage announcement (e.g. gross 2.00 / net 1.70 — 15% withholding; for withholding-exempt cases such as REITs the two are equal). A value appears only from the dividend's rights-usage day, na before that. "yield" and "paid" come from the company calendar.

Returns the company's dividend payments as a series aligned to payment bars.

symbol
string
Company symbol.
field
string
Optional. "gross"/"net" etc. (default "gross").

Note

na on non-payment bars; the whole series is na if no data.

Limits

"gross"/"net" come from the Borsa İstanbul rights-usage announcement (amount per 1 TL nominal). The difference is withholding tax (e.g. gross 2.00 → net 1.70); in withholding-exempt cases such as REITs the two are equal, which is not an error. "yield"/"paid" come from the company calendar and cover the current period only. Dates the archive does not cover return na.

CODESCRIPT
plot(dividends("THYAO", "gross"), "Dividend")

Currently always na (empty line) — no data source connected yet.

earnings(symbol, field?)

Earnings release. "actual" = reported earnings per share (trailing 12 months), sourced from the company calendar and visible only from the release date onward, na before that. "estimate" and "surprise" have no data source here — those two return na.

Returns the company's earnings releases (EPS etc.) as a series aligned to announcement bars.

symbol
string
Company symbol.
field
string
Optional. "actual"/"estimate" etc. (default "actual").

Note

na on non-announcement bars; na if no data.

Limits

Currently NOT connected to a data source — returns na on every bar (silent, no error; a one-time warning is shown on first use).

CODESCRIPT
plot(earnings("THYAO", "actual"), "Reported Profit")

Currently always na (empty line) — no data source connected yet.

economic(country, field)

Macro indicator (rate decision, inflation, confidence index...). A value appears only on bars AFTER its release; na before that (tomorrow's decision is not visible on today's bar). Countries: TR/US/EU/DE/GB/JP/CN. The code is referans platform's macro code set — for TR: INTR (policy rate), DIR, LR, CCI (consumer confidence), FER (reserves); US/EU/DE/GB/JP/CN have their own. Only RELEASED figures are supplied: forecast and previous-period values are not used. The calendar source covers the recent window; older bars return na.

Returns a country's macro indicator (rate decision, inflation, confidence index, etc.) as a series aligned to release bars.

country
string
TWO-letter country code: "TR", "US", "EU", "DE", "GB", "JP", "CN". (Three-letter forms like "TUR"/"USA" do not work.)
field
string
Indicator code. For Türkiye: INTR (policy rate), DIR, LR, CCI (consumer confidence), FER (reserves), UR (unemployment), BOT (trade balance), EXP/IMP. Other countries have their own codes (e.g. EU: INTR, CPI, GDPYY · US: CPI and NFP equivalents). Codes are uppercase.

Note

A value appears only on bars after its release, na before that — tomorrow's rate decision is not visible on today's bar. Macro indicators are released infrequently; the value is carried forward until the next release.

Limits

Only RELEASED figures are supplied. Forecast and previous-period values are NOT used: the calendar does not record when those were published, and putting today's forecast on an older bar would be backward leakage. The calendar source covers the recent window (roughly the past week plus the coming week) → older bars return na; it is not yet suitable for long-history backtests. Events without a code (ticker) in the calendar cannot be addressed either.

na if no data; macro indicators are released infrequently (the value is carried forward until the next release).

CODESCRIPT
plot(economic("TUR", "GDP"), "GDP")

Currently always na (empty line) — no data source connected yet.

financial(symbol, item, period?)

Balance-sheet/income-statement item. For BIST stocks it is read from KAP official financial statements; a value appears only on bars AFTER the statement was captured (na before that — no backward leakage). Items: TOTAL_ASSETS, TOTAL_LIABILITIES, TOTAL_CURRENT_ASSETS, TOTAL_CURRENT_LIABILITIES, TOTAL_EQUITY, COMMON_STOCK_PAR, TOTAL_REVENUE, GROSS_PROFIT, OPER_INCOME, PRETAX_INCOME, NET_INCOME; plus net_income_parent, equity_parent, noncurrent_assets, noncurrent_liabilities. TOTAL_REVENUE is read from the correct line per company type: bank → interest income, leasing/factoring → operating income, insurance → sum of technical income, holding → consolidated revenue, others → revenue. Period: FY (annual) and FQ (quarter) — for FQ, income items are separated out of the year-to-date accumulation, balance items are the quarter-end value. TTM/FH and symbols/items without data return na. Values are in full TL. The same data is supplied everywhere: normal run, optimization, forward-test, bot and scan.

Returns a company's fundamental (financial-statement) metric as a series aligned to the bars where it was reported. Values are in full TL.

symbol
string
Company symbol (e.g. "THYAO").
item
string
Item code. Balance sheet: TOTAL_ASSETS, TOTAL_LIABILITIES, TOTAL_CURRENT_ASSETS, TOTAL_CURRENT_LIABILITIES, TOTAL_EQUITY, COMMON_STOCK_PAR. Income statement: TOTAL_REVENUE, GROSS_PROFIT, OPER_INCOME, PRETAX_INCOME, NET_INCOME. Also parent-company and non-current items: net_income_parent, equity_parent, noncurrent_assets, noncurrent_liabilities. TOTAL_REVENUE is read from the correct line per company type: interest income for banks, operating income for leasing/factoring, the sum of technical income for insurers, consolidated revenue for holdings, revenue for others — so for a bank you see interest income rather than a "turnover" line, as required by the KAP statement structure.
period
string
Optional, default "FY". "FY" = annual (year-end statement). "FQ" = quarter; income items are reported cumulatively within the year, so the quarter itself is separated out, while balance items are the quarter-end value. "TTM" (trailing 12 months) and semiannual currently return na.

Note

The value applies only from its report date onward (no look-ahead); na if unavailable.

When to use

In strategies combining price with fundamentals (revenue, earnings, debt).

Limits

Read from KAP official financial statements for BIST stocks. A statement is visible only on bars after the date it was RECORDED; since the archive began on 18 May 2026, earlier bars return na (deliberate: showing a statement on an older bar, before it was known, would be backward leakage). Symbols/items/periods without data return na. The same data is supplied everywhere: normal run, optimization, forward-test, bot and scan (so optimized parameters rest on the data the bot will actually see).

CODESCRIPT
plot(financial("THYAO", "TOTAL_REVENUE", "FY"), "Annual Revenue")

Currently always na (empty line) — no data source connected yet.

htf(timeframe, source)

Higher-timeframe value (stable — it does not change on later bars).

Samples the source to the higher timeframe: once each HTF bar COMPLETES, its last value is carried forward (constant within the bar).

timeframe
string
Higher timeframe (e.g. "60", "1D", "1W").
source
series
The series to sample to the higher timeframe (e.g. close).

Note

There is NO look-ahead — the value appears only after the HTF bar closes, so it does not peek into the future (repaint-safe). A simpler shortcut than `security` for same-symbol higher timeframes.

When to use

To use a higher-timeframe trend/level (e.g. daily close, weekly average) as a filter on a lower-timeframe chart.

Limits

Until the HTF bar closes the value comes from the previous completed bar (it does not show the currently forming HTF bar). timeframe must be a valid duration.

CODESCRIPT
daily_close = htf("1D", close)
plot(daily_close, "Daily Close")

Carries the daily close onto the lower-TF chart as a step line.

CODESCRIPT
plot(close > htf("1D", sma(close, 20)) ? 1 : 0, "Above daily SMA")

1 when price is above the daily 20-SMA (a higher-TF trend filter).

quandl(code,...)

External Quandl data (discontinued → empty).

Always returns an empty (na) series — no data is provided because the source (NASDAQ Data Link) was discontinued.

code
string
Dataset code.

Note

Present for backward compatibility; it returns no functional data because the source was shut down (the upstream itself is closed).

Limits

Always na. Use `seed`/`financial`/`economic` instead.

CODESCRIPT
plot(quandl("FRED/GDP"), "Quandl")

Returns an empty (na) series — source is closed.

security(symbol, timeframe, source, gaps?, lookahead?, ignore_invalid_symbol?)

Series from another symbol/higher timeframe (source text=field name, or a series). Parameter names are English: symbol, timeframe, source. the 4th argument, gaps (barmerge.gaps_on/off), 5th lookahead (barmerge.lookahead_on/off). ignore_invalid_symbol is named-argument only: true → returns na instead of erroring on an invalid/unloaded symbol. (currency and calc_bars_count are not supported in this version.)

The series of the expression computed on the higher timeframe and aligned to the current bar without looking ahead.

symbol
string
Symbol; usually syminfo.tickerid (the current symbol) or a fixed code.
timeframe
string
Timeframe (e.g. "60", "240", "D"). Empty = chart timeframe.
source
series
Expression to compute on the higher timeframe (e.g. close, sma(close,20)).
gaps
string
Optional (4th argument in order). barmerge.gaps_on = leave gaps (na) on in-between bars; barmerge.gaps_off (default) = carry the last value forward.
lookahead
string
Optional (5th argument in order). barmerge.lookahead_off (default) = no look-ahead (causal). barmerge.lookahead_on introduces look-ahead leakage — NOT recommended in backtests.
ignore_invalid_symbol
bool
Optional, given by name ONLY (not in order). If true, an invalid/unloaded symbol returns na (empty) instead of raising an error. Default false (raises an error).

Note

The higher-timeframe value is aligned after that bar CLOSES (it does not look ahead and does not change afterward). The `currency` (FX conversion) and `calc_bars_count` parameters are NOT supported in this version — if given, they are silently ignored. The higher-timeframe value aligns only after that bar closes; the symbol and timeframe must stay constant throughout the run.

When to use

For a multi-timeframe filter (for example, trading on the 5-minute according to the 1-hour trend direction).

Limits

The symbol and timeframe must stay fixed through the run (a symbol that changes bar by bar is not supported). Until the higher-timeframe bar closes, the last closed higher-timeframe value is carried forward — so it looks flat across the forming higher-timeframe bar.

Not for

Not for a symbol or timeframe that changes bar by bar — both must stay constant through the run. If you want the same data as the chart's own timeframe, you do not need security; use close/sma(...) directly. It is not for dropping to a lower (shorter) timeframe to read data early; a higher-timeframe value aligns only after that bar closes.

Tip

The higher-timeframe value aligns only after that bar closes; the symbol and timeframe must stay constant throughout the run.

The higher-timeframe value is aligned after that bar CLOSES (it does not look ahead and does not change afterward). The `currency` (FX conversion) and `calc_bars_count` parameters are NOT supported in this version — if given, they are silently ignored.

The higher-timeframe value aligns only after that bar closes; the symbol and timeframe must stay constant throughout the run.

CODESCRIPT
plot(security(syminfo.tickerid, "60", close), "1h close", "#ff9800")

A stepped line of the 1-hour close on a 5m chart (updates every hour).

CODESCRIPT
htf = security(syminfo.tickerid, "60", sma(close,20))
enterLong(crossover(close, htf))
exit(crossunder(close, htf))

BUY when price crosses above the 1-hour SMA20 — a higher-timeframe trend filter.

securityLowerTf(symbol, tf, source)

Intrabar data from a lower timeframe (LTF): for each bar it returns the lower-TF values inside that bar as an array. The request.security_lower_tf namespace form is equivalent.

For each main-chart bar, an array of the lower-TF values that fall inside that bar, in chronological order.

symbol
string
A literal symbol string (PRIMARY or empty is not supported).
tf
string
Must be a timeframe LOWER than the main chart's (LTF).
source
series
The expression to evaluate in the LTF context (e.g. `close`).

Note

Equivalent to `request.security_lower_tf(symbol, tf, source)` (the namespace form). The `source` expression may only reference built-ins, user functions (`fn`), and independent top-level variables.

Limits

Only accepts a LOWER timeframe — passing the same or a higher TF raises a clear error (use `request.security` for that). There is a depth limit on nested `request.security*` calls; exceeding it raises an error.

CODESCRIPT
ltfCloses = securityLowerTf("BTCUSDT", "1", close)
plot(ltfCloses.size() > 0 ? ltfCloses.get(ltfCloses.size() - 1) : na)

Returns an array of 1-minute lower-TF closes for each main-chart bar; plots the last element.

seed(source, symbol)

External (seed) data series. na if no data.

Returns a symbol's series from a custom seed dataset, aligned to the bars.

source
string
Seed dataset/source name.
symbol
string
Symbol within that source.

Note

Populated only if the terminal supplies the relevant seed data; otherwise na.

Limits

If this data is not supplied by the terminal, the series is empty (na). Fundamental-data coverage varies by symbol/market.

CODESCRIPT
plot(seed("BIST_DELAY", "THYAO"), "Seed Serisi")

Plots the series from the seed source (if data exists).

splits(symbol, field?)

Bonus-issue (split) ratio. For BIST stocks it is read from Borsa İstanbul's rights-usage announcement; a value appears only from the day the rights usage starts (shares distributed), na before that. "numerator" = how many shares one share becomes (100% bonus → 2, 300% → 4, 7.829% → 1.07829), "denominator" = 1. Ratio = numerator/denominator. Paid (rights) capital increases are NOT included — those are not a share split but raising money from shareholders. The price series already arrives adjusted for bonus issues; this function is for seeing the event, not for adjusting the price.

Returns the company's stock splits as a series aligned to the bars where they happened. "numerator" is how many shares one share turns into (a 2-for-1 split gives 2) and "denominator" is 1.

symbol
string
Company symbol.
field
string
Optional. "numerator"/"denominator" (default "numerator").

Note

The value appears from the day the entitlement starts and carries forward until the next event; before that it is na.

Limits

Only BONUS (free) share distributions are recorded. Paid (rights) capital increases are deliberately excluded — those are not a share split but raising money from shareholders, and their price effect is computed differently. The source archive is collected daily from Borsa İstanbul announcements; dates the archive does not cover return na. The price series already arrives adjusted for bonus issues — this function is not for adjusting the price but for seeing which day the event happened.

na on non-split bars.

CODESCRIPT
plot(splits("THYAO", "numerator"), "Split Ratio")

Currently always na (empty line) — no data source connected yet.

sym("SYMBOL")

Another symbol's series (.open/.high/.low/.close/.volume), aligned to this chart's time. For pair-RV.

The series of another symbol (.open/.high/.low/.close/.volume), aligned to this chart's time.

symbol
string
Symbol code, e.g. "LTCUSDT".

Note

For pair/ratio strategies: ratio = close / sym("LTCUSDT").close. The returned object's fields are used in calculations like any series.

When to use

To compare two instruments on one chart, build a ratio/spread, or measure relative strength or correlation (market-neutral pairs).

Limits

At most 4 additional symbols. The data must be supplied by the terminal; if it is not loaded the call raises. Series are aligned to this chart's bar times (the secondary symbol's own gaps are carried onto the aligned grid).

Not for

Not for a higher timeframe of the same symbol — use htf or security for that. Not for fundamental data (financials/dividends) either.

CODESCRIPT
ratio = close / sym("LTCUSDT").close
plot(ratio, "Ratio")

Plots the price ratio of the two symbols (the basis of a pair/ratio strategy).

CODESCRIPT
plot(correlation(close, sym("LTCUSDT").close, 30), "Correlation")

Plots the 30-bar correlation between this symbol and LTCUSDT.

syminfoPrefix(symbol)

Exchange prefix (before ':'). Result: BINANCE

Returns the prefix before ":" in the ticker (e.g. "BIST"); an empty string if there is no ":".

symbol
string
Full ticker (e.g. "BIST:THYAO").

Note

To extract which exchange/provider a symbol belongs to.

When to use

To branch or label by the exchange/provider segment of a ticker (e.g. applying a rule only to "BIST" symbols).

Limits

Splits on the first ":"; returns an empty string for a symbol without a ":".

CODESCRIPT
label(close, syminfoPrefix("BIST:THYAO"))

Labels "BIST".

syminfoTicker(symbol)

Ticker id (after ':'). Result: BTCUSDT

With an argument, returns the symbol part after ":" (e.g. "THYAO"); called with no argument, returns the currently processed symbol.

symbol
string
Optional. Full ticker (e.g. "BIST:THYAO"). If omitted, the active context symbol.

Note

Bare syminfoTicker() yields the active symbol in multi-symbol scans (useful inside request.security loops and securityLowerTf expressions).

When to use

To get the bare symbol code without a prefix, or to learn the currently processed symbol inside a scan for labeling/logging.

Limits

The argument form takes what follows the first ":" (or the string as-is if there is no ":"). The bare form returns an empty string when no active symbol is set.

CODESCRIPT
label(close, syminfoTicker("BIST:THYAO"))

Labels "THYAO".

tickerHeikinashi(symbol)

Heikin-Ashi 'virtual ticker' marker — computes nothing by itself; pass it as the SYMBOL of security(tickerHeikinashi(symbol), tf, source) and source (close/open/high/low) then returns that symbol's Heikin-Ashi-transformed value. Empty symbol or syminfo.ticker means the current chart itself — only at the chart's OWN timeframe (tf empty/matching); a different tf errors out.

Computes nothing — returns a 'virtual ticker' marker (text) meant for security()'s SYMBOL argument. The actual Heikin-Ashi transform is applied when security() runs.

symbol
string
The symbol to take the Heikin-Ashi of. Empty, or syminfo.ticker, means the current chart itself.

Note

Mirrors the common idiom: security(tickerHeikinashi(syminfo.ticker), "" instead of timeframe.period, close). The close/open/high/low inside that call are NOT standard bars — they are the Heikin-Ashi formula (close=(o+h+l+c)/4, open=average of the previous HA-open/HA-close, high/low=max/min of the real value and HA-open/HA-close).

When to use

When you want an HA-based source (e.g. a crossover against HA-close) without switching the main chart to Heikin-Ashi.

Limits

Only works at the chart's OWN timeframe — a different timeframe (e.g. "1D" on a 1h chart) raises a clear error (it does NOT produce an approximate/wrong result). For another symbol's Heikin-Ashi, that symbol must already be loaded elsewhere in the code via sym()/security().

CodeScript operates on standard (time) bars; Heikin-Ashi bars are not produced. Instead of silently returning wrong (standard-bar) results, it raises a clear error.

CODESCRIPT
haClose = security(tickerHeikinashi(syminfo.ticker), "", close)

Takes the close from the symbol's Heikin-Ashi bars; the chart still shows normal bars while the calculation runs on smoothed ones.

tickerInherit(symbol, source)

Inherits symbol settings. Result: BTCUSDT

Returns the first ticker UNCHANGED (identity).

symbol
string
Ticker string.
source
string
Source ticker to inherit settings from.

Note

Intended for a symbol to inherit another symbol's settings; it has no effect on standard bars (a placeholder).

When to use

For syntax compatibility when porting code where one symbol inherits another's settings.

Limits

Returns the first ticker unchanged; no real setting is carried over from the source ticker.

CODESCRIPT
label(close, tickerInherit("BIST:GARAN", "BIST:THYAO"))

Returns the first ticker as-is ("BIST:GARAN").

CodeScript operates on standard (time) bars; Kagi bars are not produced. Instead of silently returning wrong (standard-bar) results, it raises a clear error.

CodeScript operates on standard (time) bars; Line-break bars are not produced. Instead of silently returning wrong (standard-bar) results, it raises a clear error.

tickerModify(symbol,...)

Modifies the ticker id. Result: BTCUSDT

Returns the ticker UNCHANGED (identity).

symbol
string
Ticker string.

Note

Intended to attach session/adjustment settings to a ticker; since CodeScript works on standard bars, this transform leaves the symbol as-is (a placeholder).

When to use

Present for syntax compatibility when porting code that attach session/adjustment settings.

Limits

Returns the ticker unchanged; no session/adjustment transform is applied.

Not for

Not for changing the bar type (renko/heikin-ashi, etc.) — those transforms raise an error here.

CODESCRIPT
label(close, tickerModify("BIST:THYAO"))

Returns the ticker as-is ("BIST:THYAO").

tickerNew(prefix, symbol)

Combined 'PREFIX:SYMBOL' ticker id. Result: BINANCE:BTCUSDT

Returns a full ticker string in "PREFIX:SYMBOL" form (just the symbol if the prefix is empty).

prefix
string
Exchange/data-provider prefix (e.g. "BINANCE", "BIST").
symbol
string
Symbol code (e.g. "BTCUSDT").

Note

Used to build a full ticker for security or sym. The result is a string, not a series.

When to use

To assemble a fully-qualified ticker from an exchange prefix + symbol to pass to security/sym.

Limits

It only concatenates text (prefix + ":" + symbol); it does not fetch data by itself. If the prefix is empty the result is just the symbol.

CODESCRIPT
label(close, tickerNew("BINANCE", "BTCUSDT"))

Builds the "BINANCE:BTCUSDT" ticker; use it in security.

CodeScript operates on standard (time) bars; Point & Figure bars are not produced. Instead of silently returning wrong (standard-bar) results, it raises a clear error.

CodeScript operates on standard (time) bars; Renko bars are not produced. Instead of silently returning wrong (standard-bar) results, it raises a clear error.

tickerStandard(symbol)

Standard ticker id. Result: BTCUSDT

Returns the ticker UNCHANGED (identity).

symbol
string
Ticker string.

Note

Intended to convert a symbol to a standard (untransformed) ticker; since CodeScript works on standard bars, this transform leaves the symbol as-is (a placeholder).

When to use

To explicitly state that a symbol should use the standard bar type (behavior is standard already).

Limits

Returns the ticker unchanged; it has no effect since CodeScript already produces standard bars.

CODESCRIPT
label(close, tickerStandard("BIST:THYAO"))

Returns the ticker as-is ("BIST:THYAO").

trade(series)

Instrument the backtest computes P&L on (instead of close). Pair/spread mode.

Does not return a value; the backtest's profit/loss is computed over this series.

series
series
The instrument whose profit/loss the backtest computes (e.g. a ratio/spread). The named argument can also be given as `price` (equivalent).

Note

For simulating trades on a ratio/spread instead of close (pair mode). If not called, the backtest uses close.

When to use

When signals are generated on a pair/ratio and P&L should be computed on that same pair (market-neutral backtest).

Limits

It may be called only once in the same code (a second call raises). The argument must be a series.

Not for

It draws nothing; use plot for visual output. It is not needed when you trade the chart symbol itself (close is the default instrument).

CODESCRIPT
x = sym("LTCUSDT")
ratio = close / x.close
trade(ratio)
enterLong(crossover(ema(ratio,5), ema(ratio,13)))
enterShort(crossunder(ema(ratio,5), ema(ratio,13)))

Trades EMA crossovers on the ratio; P&L is computed on the ratio instead of close.

securityLast(symbol, timeframe, source)

The LAST known value of another symbol/timeframe — a single number. The value is the SAME on every bar, so it is meant for panels and labels that show one figure. Do not use it in a calculation that looks back: that would leak the future — use security() there.

The last known value (a single number). Identical on every bar.

symbol
Symbol to read, e.g. "BTCUSDT". Leave "" for the chart's own symbol.
timeframe
Which timeframe, e.g. "1D" or "60". Empty uses the chart's timeframe.
source
The series or field to read: close, high, low, volume.

Note

security() aligns the secondary series to EVERY chart bar and pulls the whole range. For a single figure in a panel this form pulls far less: measured on a 3,270-bar chart, 4,200 bars sufficed instead of ~1,360,000, with identical output.

CODESCRIPT
plot(securityLast(syminfo.tickerid, "", close))

Fetches and plots the last close from another timeframe, giving the completed value rather than the bar still forming.