Built-in Functions
All functions are accessible via this inside calculate().
Moving Averages
| Function | Description |
|---|---|
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
| Function | Description |
|---|---|
this.rsi(source, period) | Relative Strength Index (0-100) |
Volatility
| Function | Description |
|---|---|
this.atr(period) | Average True Range |
this.stdev(source, period) | Standard Deviation |
Range
| Function | Description |
|---|---|
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
| Function | Description |
|---|---|
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
| Function | Description |
|---|---|
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

