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_indexyear month dayofmonth dayofweek weekofyear hour minute second(UTC;dayofweekis 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_timesyminfo.ticker / mintick / pointvalue / currency / pricescale / basecurrencytimeframe.period / multiplier / isintraday / isdailybarstate.isfirst / islast / isconfirmed ...chart.bg_color / fg_colorand thechart.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, andpi e phi. - str.*
tostring tonumber length upper lower contains startswith endswith substring replace_all format trim repeat pos split format_time.str.tostringacceptsformat.mintick,format.percent,format.volumeand patterns such as"#.#####". - color.*
new rgb from_gradient r g b tand 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.emastarts from the first value (like Pine). The built-in EMA indicator starts from an SMA. The two agree after a few hundred bars.ta.pivothighandta.pivotlowreport a pivot only once its right-hand bars exist (rightbarslate), so they never see ahead. Plot withoffset = -rightbarsto put the mark on the pivot bar.ta.kcuses an EMA of the true range. The built-in Keltner indicator uses ATR.