Functions
The full indicator catalog, argument shapes, and defaults.
Every function accepts an optional leading source argument, except atr. When omitted, each function uses its documented default series.
rsi(14) // sourced from close (the default)
rsi(high, 14) // explicit source overrideThe source argument, when present, must be a bare series identifier (close, open, high, low, volume; see OHLCV Series for what each represents), not an arbitrary expression. avg(rsi(14), 20) is a parse error.
Single-Length Functions
NAME([series,] length): one required numeric argument.
| Function | Default source | Notes |
|---|---|---|
rsi | close | Relative Strength Index |
sma | close | Simple moving average |
ema | close | Exponential moving average |
wma | close | Weighted moving average |
rma | close | Wilder's moving average |
change | close | close[0] - close[-length] |
roc | close | Rate of change |
stdev | close | Population standard deviation (divides by length, not length - 1) |
mom | close | Identical to change: see below |
max | close | Rolling maximum, inclusive of the current bar |
min | close | Rolling minimum, inclusive of the current bar |
sum | close | Rolling sum |
avg | close | Rolling mean: identical to sma, see below |
highest | high | Rolling maximum, excludes the current bar: see below |
lowest | low | Rolling minimum, excludes the current bar |
atr (No Source Argument)
atr(14)atr is sourced from high, low, and close together: there's no single series to swap in for all three, so it's the one function that rejects a source argument entirely. atr(high, 14) is a parse error.
Bollinger Bands
NAME([series,] length, mult): two required numeric arguments.
| Function | Formula |
|---|---|
bb_mid(length, mult) | sma(length) over the resolved source (mult is accepted but unused) |
bb_upper(length, mult) | bb_mid(length, mult) + mult * stdev(length) |
bb_lower(length, mult) | bb_mid(length, mult) - mult * stdev(length) |
bb_upper/bb_mid/bb_lower all default to close and accept the same source override as any other function. mult doesn't affect bb_mid, but the call still requires it: the three bb_* functions share one argument shape.
close > bb_upper(20, 2)MACD
NAME([series,] fast, slow, signal): three required numeric arguments, all three, on all three functions.
| Function | Formula |
|---|---|
macd_line(fast, slow, signal) | ema(fast) - ema(slow) over the resolved source |
macd_signal(fast, slow, signal) | An ema of period signal over macd_line's own output (not over price) |
macd_hist(fast, slow, signal) | macd_line(fast, slow, signal) - macd_signal(fast, slow, signal) |
Retail convention when unspecified: fast=12, slow=26, signal=9.
macd_line still requires all 3 arguments
macd_line doesn't mathematically use signal, but the parser requires the
identical 3-argument shape across the whole macd_* family for consistency.
macd_line(12, 26) is a parse error: write macd_line(12, 26, 9).
crossover(macd_line(12, 26, 9), macd_signal(12, 26, 9))Naming Gotchas
sma and avg
sma and avg compute the mathematically identical rolling mean, same lookback: the difference is pure naming convention. Use sma for price ("moving average"); use avg for other series like volume, so output reads idiomatically:
avg(volume, 20) // idiomatic
sma(volume, 20) // computes the same value, but reads oddlyhighest/lowest vs max/min
These look similar but are semantically distinct, not just differently named:
max/mindefault toclose, are source-flexible, and are inclusive of the current bar.highest/lowestdefault tohigh/low, and exclude the current bar: deliberately, soclose > highest(20)means "closed above the prior 20 bars' high" (a breakout), not something trivially true by including today's own high.
Use highest/lowest for breakout-framed phrases ("new 20-day high"); use max/min for a generic extreme with no breakout framing ("highest close in the last 10 bars" → max(close, 10)).
mom and change
mom(length) and change(length) currently compute the same value (close[0] - close[-length]). They're distinct names that happen to be identical today: a query may use either interchangeably, but they aren't guaranteed to stay identical in future versions.
Lookback Requirements
Every function call contributes to the query's total lookback: checked against a 300-bar ceiling at plan time. See Timeframes & Offsets for the per-function lookback formulas.