Multi-timeframe
24 entries. What each one takes, what it returns, and a working example.
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.
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).
plot(currencyRate("EUR", "USD"), "EURUSD Rate")
Currently always na (empty line) — no data source connected yet.
plot(currencyRate("USD", "USD"), "Same currency")
Plots a constant 1.0 because the same currency is given.
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.
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.
plot(dividends("THYAO", "gross"), "Dividend")
Currently always na (empty line) — no data source connected yet.
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.
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).
plot(earnings("THYAO", "actual"), "Reported Profit")
Currently always na (empty line) — no data source connected yet.
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.
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).
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.
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).
plot(financial("THYAO", "TOTAL_REVENUE", "FY"), "Annual Revenue")
Currently always na (empty line) — no data source connected yet.
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).
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.
daily_close = htf("1D", close) plot(daily_close, "Daily Close")
Carries the daily close onto the lower-TF chart as a step line.
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).
External Quandl data (discontinued → empty).
Always returns an empty (na) series — no data is provided because the source (NASDAQ Data Link) was discontinued.
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.
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.
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.
plot(security(syminfo.tickerid, "60", close), "1h close", "#ff9800")
A stepped line of the 1-hour close on a 5m chart (updates every hour).
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.
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.
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.
External (seed) data series. na if no data.
Returns a symbol's series from a custom seed dataset, aligned to the bars.
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.
plot(seed("BIST_DELAY", "THYAO"), "Seed Serisi")
Plots the series from the seed source (if data exists).
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.
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.
plot(splits("THYAO", "numerator"), "Split Ratio")
Currently always na (empty line) — no data source connected yet.
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.
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.
ratio = close / sym("LTCUSDT").close plot(ratio, "Ratio")
Plots the price ratio of the two symbols (the basis of a pair/ratio strategy).
plot(correlation(close, sym("LTCUSDT").close, 30), "Correlation")
Plots the 30-bar correlation between this symbol and LTCUSDT.
Exchange prefix (before ':'). Result: BINANCE
Returns the prefix before ":" in the ticker (e.g. "BIST"); an empty string if there is no ":".
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 ":".
label(close, syminfoPrefix("BIST:THYAO"))
Labels "BIST".
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.
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.
label(close, syminfoTicker("BIST:THYAO"))
Labels "THYAO".
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.
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.
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.
Inherits symbol settings. Result: BTCUSDT
Returns the first ticker UNCHANGED (identity).
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.
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.
Modifies the ticker id. Result: BTCUSDT
Returns the ticker UNCHANGED (identity).
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.
label(close, tickerModify("BIST:THYAO"))
Returns the ticker as-is ("BIST:THYAO").
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).
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.
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.
Standard ticker id. Result: BTCUSDT
Returns the ticker UNCHANGED (identity).
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.
label(close, tickerStandard("BIST:THYAO"))
Returns the ticker as-is ("BIST:THYAO").
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.
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).
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.
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.
plot(securityLast(syminfo.tickerid, "", close))
Fetches and plots the last close from another timeframe, giving the completed value rather than the bar still forming.