Multi-timeframe
24 entries. What each one takes, what it returns, and a working example.
Returns the exchange-rate series between two currencies. 1.0 if source = target; na if unavailable.
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 Kuru")
Currently always na (empty line) — no data source connected yet.
plot(currencyRate("USD", "USD"), "Aynı para")
Plots a constant 1.0 because the same currency is given.
Returns the company's dividend payments as a series aligned to payment bars.
na on non-payment bars; the whole series is na if no data.
plot(dividends("THYAO", "gross"), "Temettü")
Currently always na (empty line) — no data source connected yet.
Returns the company's earnings releases (EPS etc.) as a series aligned to announcement bars.
na on non-announcement bars; na if no data.
plot(earnings("THYAO", "actual"), "Açıklanan Kâr")
Currently always na (empty line) — no data source connected yet.
Returns a country's economic indicator (GDP, inflation, etc.) as a series aligned to release bars.
na if no data; macro indicators are released infrequently (the value is carried forward until the next release).
plot(economic("TUR", "GDP"), "GSYİH")
Currently always na (empty line) — no data source connected yet.
financial(sembol, kalem, dönem?)
Returns a company's fundamental (financial-statement) metric as a series aligned to the bars where it was reported.
The value applies only from its report date onward (no look-ahead); na if unavailable.
plot(financial("THYAO", "TOTAL_REVENUE", "FY"), "Yıllık Gelir")
Currently always na (empty line) — no data source connected yet.
Samples the source to the higher timeframe: once each HTF bar COMPLETES, its last value is carried forward (constant within the bar).
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.
gunluk_kapanis = htf("1D", close) plot(gunluk_kapanis, "Günlük Kapanış")
Carries the daily close onto the lower-TF chart as a step line.
plot(close > htf("1D", sma(close, 20)) ? 1 : 0, "Günlük SMA üstünde")
1 when price is above the daily 20-SMA (a higher-TF trend filter).
Always returns an empty (na) series — no data is provided because the source (NASDAQ Data Link) was discontinued.
Present for backward compatibility; it returns no functional data because the source was shut down (the upstream itself is closed).
plot(quandl("FRED/GDP"), "Quandl")
Returns an empty (na) series — source is closed.
security(symbol, timeframe, source, gaps?, lookahead?, ignore_invalid_symbol?)
The series of the expression computed on the higher timeframe and aligned to the current bar without looking ahead.
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), "1s kapanış", "#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(sembol, tf, kaynak)
For each main-chart bar, an array of the lower-TF values that fall inside that bar, in chronological order.
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.
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.
Returns a symbol's series from a custom seed dataset, aligned to the bars.
Populated only if the terminal supplies the relevant seed data; otherwise na.
plot(seed("BIST_DELAY", "THYAO"), "Seed Serisi")
Plots the series from the seed source (if data exists).
Returns the company's stock splits as a series aligned to split bars.
na on non-split bars.
plot(splits("THYAO", "numerator"), "Bölünme Payı")
Currently always na (empty line) — no data source connected yet.
The series of another symbol (.open/.high/.low/.close/.volume), aligned to this chart's time.
For pair/ratio strategies: ratio = close / sym("LTCUSDT").close. The returned object's fields are used in calculations like any series.
oran = close / sym("LTCUSDT").close plot(oran, "Oran")
Plots the price ratio of the two symbols (the basis of a pair/ratio strategy).
plot(correlation(close, sym("LTCUSDT").close, 30), "Korelasyon")
Plots the 30-bar correlation between this symbol and LTCUSDT.
Returns the prefix before ":" in the ticker (e.g. "BIST"); an empty string if there is no ":".
To extract which exchange/provider a symbol belongs to.
label(close, syminfoPrefix("BIST:THYAO"))
Labels "BIST".
With an argument, returns the symbol part after ":" (e.g. "THYAO"); called with no argument, returns the currently processed symbol.
Bare syminfoTicker() yields the active symbol in multi-symbol scans (useful inside request.security loops and securityLowerTf expressions).
label(close, syminfoTicker("BIST:THYAO"))
Labels "THYAO".
RAISES an error — the Heikin-Ashi bar-type transform is not supported by CodeScript.
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.
Returns the first ticker UNCHANGED (identity).
Intended for a symbol to inherit another symbol's settings; it has no effect on standard bars (a placeholder).
label(close, tickerInherit("BIST:GARAN", "BIST:THYAO"))
Returns the first ticker as-is ("BIST:GARAN").
RAISES an error — the Kagi bar-type transform is not supported by CodeScript.
CodeScript operates on standard (time) bars; Kagi bars are not produced. Instead of silently returning wrong (standard-bar) results, it raises a clear error.
RAISES an error — the Line-break bar-type transform is not supported by CodeScript.
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.
Intended to attach session/adjustment settings to a ticker; since CodeScript works on standard bars, this transform leaves the symbol as-is (a placeholder).
label(close, tickerModify("BIST:THYAO"))
Returns the ticker as-is ("BIST:THYAO").
Returns a full ticker string in "PREFIX:SYMBOL" form (just the symbol if the prefix is empty).
Used to build a full ticker for security or sym. The result is a string, not a series.
label(close, tickerNew("BINANCE", "BTCUSDT"))
Builds the "BINANCE:BTCUSDT" ticker; use it in security.
tickerPointfigure(sembol, ...)
RAISES an error — the Point & Figure bar-type transform is not supported by CodeScript.
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.
RAISES an error — the Renko bar-type transform is not supported by CodeScript.
CodeScript operates on standard (time) bars; Renko bars are not produced. Instead of silently returning wrong (standard-bar) results, it raises a clear error.
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).
label(close, tickerStandard("BIST:THYAO"))
Returns the ticker as-is ("BIST:THYAO").
Does not return a value; the backtest's profit/loss is computed over this series.
For simulating trades on a ratio/spread instead of close (pair mode). If not called, the backtest uses close.
x = sym("LTCUSDT") oran = close / x.close trade(oran) enterLong(crossover(ema(oran,5), ema(oran,13))) enterShort(crossunder(ema(oran,5), ema(oran,13)))
Trades EMA crossovers on the ratio; P&L is computed on the ratio instead of close.