Skip to content

Built-in Functions

All functions are accessible via this inside calculate().

Moving Averages

FunctionDescription
this.sma(source, period)Simple Moving Average
this.ema(source, period)Exponential Moving Average
this.wma(source, period)Weighted Moving Average
this.rma(source, period)Smoothed Moving Average (Wilder's)
this.linreg(source, period)Linear Regression value

Oscillators

FunctionDescription
this.rsi(source, period)Relative Strength Index (0-100)

Volatility

FunctionDescription
this.atr(period)Average True Range
this.stdev(source, period)Standard Deviation

Range

FunctionDescription
this.highest(source, period)Highest value in lookback
this.lowest(source, period)Lowest value in lookback
this.sum(source, period)Sum of values in lookback

Crossovers

FunctionDescription
this.crossOver(cur1, cur2, prev1, prev2)True if series 1 crosses above series 2
this.crossUnder(cur1, cur2, prev1, prev2)True if series 1 crosses below series 2

Math

FunctionDescription
this.abs(value)Absolute value
this.max(...values)Maximum of values
this.min(...values)Minimum of values
this.round(value, decimals?)Round to N decimal places

Source Parameter

The source parameter accepts:

  • Data series: 'open', 'high', 'low', 'close', 'volume'
  • Computed: 'hl2', 'hlc3', 'ohlc4'
  • Plot names: Reference your own plotted values

ChartLabs Documentation