TradeOnReplayDOCSSearch the whole guidetradeonreplay.com

Guide / Scripts

Built-in series and functions

Type a name in the editor and press Ctrl Space for the full list with parameters. The list is generated from the same tables the compiler uses, so it never drifts.

Series

  • open high low close volume time hl2 hlc3 ohlc4 hlcc4 bar_index
  • year month dayofmonth dayofweek weekofyear hour minute second (UTC; dayofweek is 1 = Sunday)
  • ta.tr ta.obv ta.accdist ta.pvt ta.nvi ta.pvi ta.wad ta.wvad ta.iii, ta.vwap / vwap (restarts each UTC day)
  • time_close, last_bar_time
  • syminfo.ticker / mintick / pointvalue / currency / pricescale / basecurrency
  • timeframe.period / multiplier / isintraday / isdaily
  • barstate.isfirst / islast / isconfirmed ...
  • chart.bg_color / fg_color and the chart.is_* flags

ta.*

Moving averages: sma ema rma wma vwma swma hma alma linreg median mode cog.
Oscillators: rsi cci mfi cmo tsi wpr stoch macd.
Bands and ranges: bb bbw kc kcw atr tr dmi sar supertrend.
Statistics: stdev variance dev highest lowest highestbars lowestbars range max min change mom roc percentrank percentile_nearest_rank percentile_linear_interpolation correlation.
Events: crossover crossunder cross rising falling cum valuewhen barssince pivothigh pivotlow.

The older bare names (sma, rsi, ...) still work.

math, str, color, time

  • math.* abs ceil floor round sqrt pow log log10 exp sign sin cos tan asin acos atan todegrees toradians max min avg sum round_to_mintick, and pi e phi.
  • str.* tostring tonumber length upper lower contains startswith endswith substring replace_all format trim repeat pos split format_time. str.tostring accepts format.mintick, format.percent, format.volume and patterns such as "#.#####".
  • color.* new rgb from_gradient r g b t and the named colours.
  • time year(time) month(time) ... timestamp(y, m, d, h, mi), all UTC.
  • general na nz fixnan int float bool

Sessions and time of day

time(timeframe, session) is the bar's timeframe start ("D", "W" starting Monday, "M", "60"), or na when the bar is outside session. Sessions look like "0800-1600", "2200-0600", or "0800-1600:23456" for chosen days (1 = Sunday), all in UTC. timeframe.change("D") is true on the first bar of each new day, and timeframe.in_seconds("60") converts a timeframe.

Where it differs from TradingView

  • ta.ema starts from the first value (like Pine). The built-in EMA indicator starts from an SMA. The two agree after a few hundred bars.
  • ta.pivothigh and ta.pivotlow report a pivot only once its right-hand bars exist (rightbars late), so they never see ahead. Plot with offset = -rightbars to put the mark on the pivot bar.
  • ta.kc uses an EMA of the true range. The built-in Keltner indicator uses ATR.