Signal DSL Operators
This reference is generated from the executable EXPRESSION_OPERATOR_REGISTRY. The runtime registry is authoritative for operator availability; this document is its searchable canonical Docs projection.
Use execution dsl-grammar for the complete strategy-authoring grammar and docs search with topic strategies/operators for complete operator documentation.
Documented executable operators: 252.
Indicator
ad
Signature: ad(high, low, close, volume)
Returns: numeric
Accumulation/Distribution.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
volume | Series | yes | — |
adr
Signature: adr(high, low, length=14)
Returns: numeric
Average Day Range — SMA of (high - low).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
length | int | no | 14 |
adx
Signature: adx(high, low, close, di_length=14, adx_smoothing=14)
Returns: numeric
Average Directional Index — FE-compatible implementation (returns ADX line only).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
di_length | int | no | 14 |
adx_smoothing | int | no | 14 |
adxr
Signature: adxr(high, low, close, window=14)
Returns: numeric
Average Directional Movement Rating.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
window | int | no | 14 |
alma
Signature: alma(data, length=9, offset=0.85, sigma=6.0)
Returns: numeric
Arnaud Legoux Moving Average.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
length | int | no | 9 |
offset | float | no | 0.85 |
sigma | float | no | 6.0 |
apo
Signature: apo(data, fast=12, slow=26)
Returns: numeric
Absolute Price Oscillator.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
fast | int | no | 12 |
slow | int | no | 26 |
aroon
Signature: aroon(high, low, length=14)
Returns: tuple
Aroon — returns (up, down).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
length | int | no | 14 |
aroon_down
Signature: aroon_down(high, low, length=14)
Returns: numeric
Aroon Down (0-100).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
length | int | no | 14 |
aroon_oscillator
Signature: aroon_oscillator(high, low, length=14)
Returns: numeric
Aroon Oscillator (Aroon Up - Aroon Down).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
length | int | no | 14 |
aroon_up
Signature: aroon_up(high, low, length=14)
Returns: numeric
Aroon Up (0-100).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
length | int | no | 14 |
atr
Signature: atr(high, low, close, window=14)
Returns: numeric
Average True Range — Wilder RMA of true range with FE-compatible seeding.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
window | int | no | 14 |
avgprice
Signature: avgprice(open, high, low, close)
Returns: numeric
Average Price.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | Series | yes | — |
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
awesome_oscillator
Signature: awesome_oscillator(high, low, fast=5, slow=34)
Returns: numeric
Awesome Oscillator (median-price SMA difference).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
fast | int | no | 5 |
slow | int | no | 34 |
bb
Signature: bb(data, length=20, mult=2.0)
Returns: tuple
Bollinger Bands — returns (upper, middle, lower). Example: upper, middle, lower = bb(close, 20, 2.0)
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
length | int | no | 20 |
mult | float | no | 2.0 |
bb_bandwidth
Signature: bb_bandwidth(close, length=20, mult=2.0)
Returns: numeric
Bollinger BandWidth (FE formula): (upper - lower) / basis * 100. basis = SMA(close, length); dev = stdev_pop(close, length) * mult; upper = basis + dev; lower = basis - dev.
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
length | int | no | 20 |
mult | float | no | 2.0 |
bb_lower
Signature: bb_lower(data, length=20, mult=2.0)
Returns: numeric
Bollinger Lower Band.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
length | int | no | 20 |
mult | float | no | 2.0 |
bb_middle
Signature: bb_middle(data, length=20, mult=2.0)
Returns: numeric
Bollinger Middle Band.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
length | int | no | 20 |
mult | float | no | 2.0 |
bb_percent_b
Signature: bb_percent_b(close, length=20, mult=2.0)
Returns: numeric
Bollinger %B — (close - lower) / (upper - lower).
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
length | int | no | 20 |
mult | float | no | 2.0 |
bb_upper
Signature: bb_upper(data, length=20, mult=2.0)
Returns: numeric
Bollinger Upper Band.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
length | int | no | 20 |
mult | float | no | 2.0 |
bbtrend
Signature: bbtrend(close, short_length=20, long_length=50, mult=2.0)
Returns: numeric
BBTrend (FE formula): (|sL - lL| - |sU - lU|) / sM * 100. sM = SMA(close, short_length); dev_short = stdev_pop(close, short_length) * mult; sU = sM + dev_short; sL = sM - dev_short; similarly for long_length.
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
short_length | int | no | 20 |
long_length | int | no | 50 |
mult | float | no | 2.0 |
bollinger_bands
Signature: bollinger_bands(data, length=20, mult=2.0)
Returns: tuple
Long-form alias for bb — returns (upper, middle, lower). The frontend's signal/mean_reversion template emits upper, middle, lower = bollinger_bands(close, 20, 2.0); we expose this name as a registered indicator so the validator and engine both resolve it to the same Bollinger implementation as bb.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
length | int | no | 20 |
mult | float | no | 2.0 |
bop
Signature: bop(open, high, low, close)
Returns: numeric
Balance of Power.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | Series | yes | — |
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
bull_bear_power
Signature: bull_bear_power(high, low, close, length=13)
Returns: numeric
Bull Bear Power — (high - ema) + (low - ema).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
length | int | no | 13 |
cci
Signature: cci(high, low, close, window=20)
Returns: numeric
Commodity Channel Index.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
window | int | no | 20 |
chaikin_mf
Signature: chaikin_mf(high, low, close, volume, length=20)
Returns: numeric
Chaikin Money Flow.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
volume | Series | yes | — |
length | int | no | 20 |
chaikin_osc
Signature: chaikin_osc(high, low, close, volume, fast=3, slow=10)
Returns: numeric
Chaikin Oscillator (FE formula): EMA(AD, fast) - EMA(AD, slow). Accumulation/Distribution (AD) is cumulative: if high == low: AD unchanged. else: clv = (close - low - (high - close)) / (high - low); AD += clv * volume. EMAs are FE-style seeded EMAs.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
volume | Series | yes | — |
fast | int | no | 3 |
slow | int | no | 10 |
chande_kroll_stop
Signature: chande_kroll_stop(high, low, close, p=10, x=1.0, q=9)
Returns: numeric
Chande Kroll Stop (FE plot0, Stop Long). FE: highestHigh = ta.highest(high, atrLength); lowestLow = ta.lowest(low, atrLength); atrArr = ta.atr(bars, atrLength); firstHighStop = hh - atrCoeffatr; firstLowStop = ll + atrCoeffatr; stopLong (plot0) = ta.lowest(firstLowStop, stopLength). Warmup NaN until atr+highest/lowest are all valid AND stopLength window of firstLowStop is entirely valid.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
p | int | no | 10 |
x | float | no | 1.0 |
q | int | no | 9 |
chande_mo
Signature: chande_mo(data, window=9)
Returns: numeric
Chande Momentum Oscillator. FE formula: at each bar i (i >= length), compute sum of gains and sum of absolute losses over the last length bars (mom = close[i] - close[i-1] for i in window), then CMO = 100 * (sumGains - sumLosses) / (sumGains + sumLosses). Warmup: NaN for i < length.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | no | 9 |
chop_zone
Signature: chop_zone(close, length=34)
Returns: numeric
Chop Zone (FE plot0) — a coloring-only indicator; plot value is always 1. FE ChopZone.calculate pushes value: 1 for every bar (color varies by emaAngle). Since parity is on numeric values only, DSL returns a constant-1 series of the same length. length is kept for signature parity (FE hardcodes EMA=34 internally).
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
length | int | no | 34 |
choppiness
Signature: choppiness(high, low, close, length=14)
Returns: numeric
Choppiness Index.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
length | int | no | 14 |
connors_rsi
Signature: connors_rsi(close, rsi_len=3, streak_len=2, rank_len=100)
Returns: numeric
Connors RSI — (rsi(close, rsi_len) + rsi(ud, streak_len) + percentrank(roc(close,1), rank_len)) / 3. Matches FE calculate78(): ud[0]=0; if close[i]==close[i-1]: 0; if close[i]>close[i-1]: (ud[i-1]<=0 ? 1 : ud[i-1]+1); else (ud[i-1]>=0 ? -1 : ud[i-1]-1). roc1 = ta.roc(close, 1) (NaN for i<1, else 100*(c[i]-c[i-1])/c[i-1]). pr = ta.percentrank(roc1, rank_len) (NaN for i<rank_len or any NaN in window; else count(prior<=cur)/rank_len*100).
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
rsi_len | int | no | 3 |
streak_len | int | no | 2 |
rank_len | int | no | 100 |
coppock_curve
Signature: coppock_curve(data, wma_length=10, long_roc=14, short_roc=11)
Returns: numeric
Coppock Curve — WMA(ROC(long) + ROC(short), wma_length).
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
wma_length | int | no | 10 |
long_roc | int | no | 14 |
short_roc | int | no | 11 |
cvd
Signature: cvd(open, close, volume)
Returns: numeric
Cumulative Volume Delta.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | Series | yes | — |
close | Series | yes | — |
volume | Series | yes | — |
dema
Signature: dema(data, window)
Returns: numeric
Double Exponential Moving Average.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | yes | — |
dmi
Signature: dmi(high, low, close, di_length=14, adx_smoothing=14)
Returns: tuple
Directional Movement Index — returns (adx, +DI, -DI) to match FE plot order. FE plotConfig66: plot0=ADX, plot1=+DI, plot2=-DI. test_matrix maps {plot0:0, plot1:1, plot2:2} → DSL tuple index 0 must be ADX.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
di_length | int | no | 14 |
adx_smoothing | int | no | 14 |
dmi_minus_di
Signature: dmi_minus_di(high, low, close, di_length=14)
Returns: numeric
-DI line using FE DMI formula (calculate66 in FE index.mjs).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
di_length | int | no | 14 |
dmi_plus_di
Signature: dmi_plus_di(high, low, close, di_length=14)
Returns: numeric
+DI line using FE DMI formula (calculate66 in FE index.mjs).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
di_length | int | no | 14 |
donchian
Signature: donchian(high, low, length=20)
Returns: tuple
Donchian Channels (FE): returns (upper, middle, lower). upper = ta.highest(high, length); lower = ta.lowest(low, length); middle = (upper+lower)/2. All three are NaN for i<length-1 (matches oakscriptjs ta.highest/lowest warmup).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
length | int | no | 20 |
donchian_lower
Signature: donchian_lower(low, length=20)
Returns: numeric
Donchian lower band (rolling lowest low).
| Parameter | Type | Required | Default |
|---|---|---|---|
low | Series | yes | — |
length | int | no | 20 |
donchian_middle
Signature: donchian_middle(high, low, length=20)
Returns: numeric
Donchian middle band ((upper + lower) / 2).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
length | int | no | 20 |
donchian_upper
Signature: donchian_upper(high, length=20)
Returns: numeric
Donchian upper band (rolling highest high).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
length | int | no | 20 |
dpo
Signature: dpo(data, length=21)
Returns: numeric
Detrended Price Oscillator.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
length | int | no | 21 |
elder_force
Signature: elder_force(close, volume, length=13)
Returns: numeric
Elder Force Index (FE formula): ema(force, length) with force[0]=NaN, force[i]=(close[i]-close[i-1])*(volume[i] or 0). Uses SMA-seeded EMA.
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
volume | Series | yes | — |
length | int | no | 13 |
ema
Signature: ema(data, window)
Returns: numeric
Exponential Moving Average.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | yes | — |
envelope
Signature: envelope(close, length=20, percent=10.0, exponential=False)
Returns: numeric
Envelope basis line (FE plot0) — SMA (or EMA) of close with FE-seeded MA. FE Envelope returns plot0=basis, plot1=basis*(1+k), plot2=basis*(1-k) with k=percent/100. DSL returns the basis so parity matches plot0.
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
length | int | no | 20 |
percent | float | no | 10.0 |
exponential | bool | no | False |
eom
Signature: eom(high, low, volume, length=14, divisor=10000)
Returns: numeric
Ease of Movement.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
volume | Series | yes | — |
length | int | no | 14 |
divisor | int | no | 10000 |
fisher_transform
Signature: fisher_transform(high, low, length=9)
Returns: numeric
Fisher Transform (FE formula, plot0 only). For each bar: hl2 = (high+low)/2; lookback = min(i+1, length) find highest/lowest hl2 over last lookback bars (inclusive) normalized = (hl2 - lowest) / (highest - lowest) - 0.5 if range != 0 else 0 rawValue = 0.66 * normalized + 0.67 * prevValue (clipped at ±0.99→±0.999) fish1 = 0.5 * log((1+value) / (1-value)) + 0.5 * prevFish1 plot0 returns fish1 with NaN for i < length - 1.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
length | int | no | 9 |
heikin_ashi_close
Signature: heikin_ashi_close(open, high, low, close)
Returns: numeric
Heikin Ashi Close.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | Series | yes | — |
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
heikin_ashi_open
Signature: heikin_ashi_open(open, close)
Returns: numeric
Heikin Ashi Open (approximated).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | Series | yes | — |
close | Series | yes | — |
highest
Signature: highest(data, window=20)
Returns: numeric
Rolling highest value over window.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | no | 20 |
hist_volatility
Signature: hist_volatility(close, length=10, annual=365, per=1)
Returns: numeric
Historical Volatility (FE formula): population stdev of log returns * 100 * sqrt(annual/per). logReturns[0] = NaN; logReturns[i] = log(close[i]/close[i-1]). Result at i < length-1 is NaN (from stdev warmup, since logReturns[0] is NaN); effectively valid from i == length (need length non-NaN log returns).
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
length | int | no | 10 |
annual | int | no | 365 |
per | int | no | 1 |
historical_sr
Signature: historical_sr(high, low, close, sr_type, rank=1, lookback_period=252, cluster_pct=0.005, recency_decay=0.01, swing_order=5)
Returns: numeric
Calculates historical support and resistance levels, optimized with Numba.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
sr_type | str | yes | — |
rank | int | no | 1 |
lookback_period | int | no | 252 |
cluster_pct | float | no | 0.005 |
recency_decay | float | no | 0.01 |
swing_order | int | no | 5 |
hma
Signature: hma(data, window)
Returns: numeric
Hull Moving Average.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | yes | — |
ichimoku
Signature: ichimoku(high, low, close, conversion=9, base=26, span_b=52, displacement=26)
Returns: tuple
Ichimoku Cloud (FE calculate12) — returns (tenkan, kijun, span_a, span_b, chikou). conversionLine = donchian(high, low, conversion) # (highest+lowest)/2, NaN warmup baseLine = donchian(high, low, base) leadingSpanA = (conversionLine + baseLine) / 2 then SHIFTED FORWARD by (displacement-1) leadingSpanB = donchian(high, low, span_b) then SHIFTED FORWARD by (displacement-1) chikou = close shifted BACKWARD by (displacement-1) (sourceIndex = i + (displacement-1)) Plot order in FE: plot0=conversion, plot1=base, plot2=lagging(chikou), plot3=leadA, plot4=leadB. DSL tuple here: (tenkan, kijun, span_a, span_b, chikou) i.e. (0,1,2,3,4). test_matrix maps FE plot0→0, plot1→1, plot2→4, plot3→2, plot4→3.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
conversion | int | no | 9 |
base | int | no | 26 |
span_b | int | no | 52 |
displacement | int | no | 26 |
ichimoku_chikou
Signature: ichimoku_chikou(close, displacement=26)
Returns: numeric
Ichimoku Chikou (Lagging Span) — close shifted backward by displacement.
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
displacement | int | no | 26 |
ichimoku_kijun
Signature: ichimoku_kijun(high, low, length=26)
Returns: numeric
Ichimoku Kijun-sen (Base Line).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
length | int | no | 26 |
ichimoku_span_a
Signature: ichimoku_span_a(high, low, conversion=9, base=26)
Returns: numeric
Ichimoku Leading Span A.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
conversion | int | no | 9 |
base | int | no | 26 |
ichimoku_span_b
Signature: ichimoku_span_b(high, low, length=52)
Returns: numeric
Ichimoku Leading Span B.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
length | int | no | 52 |
ichimoku_tenkan
Signature: ichimoku_tenkan(high, low, length=9)
Returns: numeric
Ichimoku Tenkan-sen (Conversion Line).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
length | int | no | 9 |
kama
Signature: kama(data, window=10)
Returns: numeric
Kaufman Adaptive Moving Average.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | no | 10 |
keltner
Signature: keltner(high, low, close, length=20, mult=2.0, atr_length=10)
Returns: tuple
Keltner Channels (FE defaults: useEMA=true, src='close', bandsStyle='ATR'). Returns (upper, middle, lower). Upper = basis + multatr; Lower = basis - multatr.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
length | int | no | 20 |
mult | float | no | 2.0 |
atr_length | int | no | 10 |
keltner_lower
Signature: keltner_lower(high, low, close, length=20, mult=2.0, atr_length=10)
Returns: numeric
Keltner Channel lower band.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
length | int | no | 20 |
mult | float | no | 2.0 |
atr_length | int | no | 10 |
keltner_middle
Signature: keltner_middle(high, low, close, length=20)
Returns: numeric
Keltner Channel middle (basis) line — FE uses ema(close, length) by default.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
length | int | no | 20 |
keltner_upper
Signature: keltner_upper(high, low, close, length=20, mult=2.0, atr_length=10)
Returns: numeric
Keltner Channel upper band (FE default bandsStyle='Average True Range').
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
length | int | no | 20 |
mult | float | no | 2.0 |
atr_length | int | no | 10 |
klinger
Signature: klinger(high, low, close, volume, fast_length=34, slow_length=55, signal_length=13)
Returns: numeric
Klinger Oscillator (FE plot0): EMA(signedVolume, fast) - EMA(signedVolume, slow). Matches FE calculate67 exactly: hlc3 = (high+low+close)/3; hlc3ChangeArr = ta.change(hlc3Series, 1).toArray() # NaN at i=0 if (change === null) signedVolume.push(volume) # strict null, NOT NaN else signedVolume.push(change >= 0 ? volume : -volume) FE's change === null check does NOT match NaN at i=0 (NaN !== null). So at i=0: NaN >= 0 is false → push -volume.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
volume | Series | yes | — |
fast_length | int | no | 34 |
slow_length | int | no | 55 |
signal_length | int | no | 13 |
kst
Signature: kst(data, roc1=10, roc2=15, roc3=20, roc4=30, sma1=10, sma2=10, sma3=10, sma4=15)
Returns: numeric
Know Sure Thing — weighted ROC composite.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
roc1 | int | no | 10 |
roc2 | int | no | 15 |
roc3 | int | no | 20 |
roc4 | int | no | 30 |
sma1 | int | no | 10 |
sma2 | int | no | 10 |
sma3 | int | no | 10 |
sma4 | int | no | 15 |
linear_reg
Signature: linear_reg(data, window=20)
Returns: numeric
Linear regression line over window.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | no | 20 |
linear_reg_slope
Signature: linear_reg_slope(data, window=20)
Returns: numeric
Linear regression slope over window.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | no | 20 |
lowest
Signature: lowest(data, window=20)
Returns: numeric
Rolling lowest value over window.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | no | 20 |
lsma
Signature: lsma(data, length=25, offset=0)
Returns: numeric
Least Squares Moving Average (linear regression of the closing price).
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
length | int | no | 25 |
offset | int | no | 0 |
ma
Signature: ma(data, window)
Returns: numeric
Moving Average (alias for SMA).
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | yes | — |
macd
Signature: macd(data, fast=12, slow=26, signal=9)
Returns: tuple
MACD — returns (line, signal, histogram). Uses FE-style seeded EMAs. FE calculates: fastEMA - slowEMA, then EMA(signal) of the line, hist = line - signal.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
fast | int | no | 12 |
slow | int | no | 26 |
signal | int | no | 9 |
macd_hist
Signature: macd_hist(data, fast=12, slow=26, signal=9)
Returns: numeric
MACD histogram only.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
fast | int | no | 12 |
slow | int | no | 26 |
signal | int | no | 9 |
macd_line
Signature: macd_line(data, fast=12, slow=26, signal=9)
Returns: numeric
MACD line only.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
fast | int | no | 12 |
slow | int | no | 26 |
signal | int | no | 9 |
macd_signal
Signature: macd_signal(data, fast=12, slow=26, signal=9)
Returns: numeric
MACD signal line only.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
fast | int | no | 12 |
slow | int | no | 26 |
signal | int | no | 9 |
mass_index
Signature: mass_index(high, low, length=10)
Returns: numeric
Mass Index (FE formula): sum(ratio, length) where ratio = ema1/ema2 of (high-low). ema1 = SMA-seeded EMA(range, 9); ema2 = SMA-seeded EMA(ema1, 9). Requires the full length-bar window to be non-NaN (FE gates on validCount === length).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
length | int | no | 10 |
mc_ginley_dynamic
Signature: mc_ginley_dynamic(data, length=14, k=1.0)
Returns: numeric
McGinley Dynamic MA (FE formula): md[i] = md[i-1] + (src - md[i-1]) / (length * ratio^4). FE hardcodes the denom coefficient at 1.0 (k * length * ratio^4 with k=1); the k parameter is preserved for backwards compatibility but defaults to 1.0 so DSL matches FE's McGinleyDynamic.calculate() when called with default params. Seeds md[0] = srcVal; resets to srcVal if prev md is None/0.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
length | int | no | 14 |
k | float | no | 1.0 |
median
Signature: median(data, length=3)
Returns: numeric
Rolling median using FE percentileNearestRank (50%) over length bars. Matches FE ta.percentileNearestRank: sorted index = ceil(0.5 * len) - 1. For even-length windows this returns the lower of the two middles (Pine-style), not the arithmetic mean. NaN for i < length - 1.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
length | int | no | 3 |
medprice
Signature: medprice(high, low)
Returns: numeric
Median Price.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
mfi
Signature: mfi(high, low, close, volume, window=14)
Returns: numeric
Money Flow Index.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
volume | Series | yes | — |
window | int | no | 14 |
momentum
Signature: momentum(data, window=10)
Returns: numeric
Momentum (price difference over window).
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | no | 10 |
natr
Signature: natr(high, low, close, window=14)
Returns: numeric
Normalized Average True Range.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
window | int | no | 14 |
net_volume
Signature: net_volume(open, close, volume)
Returns: numeric
Net Volume — alias of volume_delta.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | Series | yes | — |
close | Series | yes | — |
volume | Series | yes | — |
obv
Signature: obv(close, volume)
Returns: numeric
On Balance Volume — cumulative sign(close_diff) * volume, starts at 0.
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
volume | Series | yes | — |
parabolic_sar
Signature: parabolic_sar(high, low, close, af_start=0.02, af_increment=0.02, af_max=0.2)
Returns: numeric
Parabolic SAR — exact match to FE oakscriptjs ta.sar(bars, start, inc, max). Algorithm (per FE/oakscriptjs sar): - result[0] = NaN. - At i=1, seed direction from close[1] vs close[0]: if up, ep=high[1], sar=low[0]; else ep=low[1], sar=high[0]. Mark isFirstTrendBar=true, accel=start. - sar = sar + accel * (ep - sar). Check reversal: if uptrend and sar>low[i], reverse (isUp=false, sar=max(high[i], ep), ep=low[i], accel=start). Similar for down. - If NOT first-trend-bar and (uptrend & high[i]>ep OR !uptrend & low[i]<ep), update ep to extreme, accel = min(accel + inc, max). - Clamp: if uptrend, sar = min(sar, low[i-1], low[i-2] if i>1); if downtrend, sar = max(sar, high[i-1], high[i-2] if i>1). Push sar. Clear isFirstTrendBar.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
af_start | float | no | 0.02 |
af_increment | float | no | 0.02 |
af_max | float | no | 0.2 |
pivot
Signature: pivot(high, low, close, level='P')
Returns: numeric
Calculates classic pivot points based on the provided data.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
level | str | no | 'P' |
price_oscillator
Signature: price_oscillator(data, short=12, long=26, signal=9, exponential=True)
Returns: numeric
Price Oscillator histogram (FE plot0): ppo - signal_ema(ppo). ppo = (shortMA - longMA) / longMA * 100. With exponential=True (FE default), MA is FE-seeded EMA; otherwise SMA. signal line is EMA(ppo, signal). Returns histogram = ppo - signal_line (matches FE plot0 which is columns style).
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
short | int | no | 12 |
long | int | no | 26 |
signal | int | no | 9 |
exponential | bool | no | True |
pvt
Signature: pvt(close, volume)
Returns: numeric
Price Volume Trend — cumulative (pct_change * volume).
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
volume | Series | yes | — |
rci
Signature: rci(close, length=9)
Returns: numeric
Rank Correlation Index (FE ta.rci): tie-corrected Spearman of source vs time. For each bar i >= length-1: take window of length source values, assign average ranks within ties. Let sumSquaredDiff = sum((rank[j] - (j+1))^2). Let base = (n^3 - n)/12; tieCorrection = sum((tc^3 - tc)/12 for each tie-group of size tc>=2); A = base - tieCorrection, B = base. If A or B == 0 → rho = 0 else rho = (A + B - sumSquaredDiff) / (2 * sqrt(AB)). Result = rho100. NaN if any source is NaN.
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
length | int | no | 9 |
rci_ribbon
Signature: rci_ribbon(close, length=9)
Returns: numeric
RCI Ribbon — single length wrapper; use rci(close, length).
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
length | int | no | 9 |
relative_volume_at_time
Signature: relative_volume_at_time(volume, time, length=10)
Returns: numeric
Relative Volume at Time (FE calculate70, anchor='1D', cumulative mode). Per-bar cumulative volume within the daily period; ratio = current / avg of same intra-day offset across the last length prior periods. Last-bar adjustRealtime is NOT applied here (it only fires for the final partial bar on live charts; the parity fixture only has completed historical bars). For the final historical bar, FE's adjustRealtime path scales current vs. full expected period duration. We replicate FE exactly: if i == n-1 and timePassed > 0 and timePassed < periodDuration, scale currentValue.
| Parameter | Type | Required | Default |
|---|---|---|---|
volume | Series | yes | — |
time | Series | yes | — |
length | int | no | 10 |
rma
Signature: rma(data, length=14)
Returns: numeric
Wilder's Smoothed Moving Average — SMA-seeded at bar length-1, alpha = 1/length.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
length | int | no | 14 |
roc
Signature: roc(data, window=10)
Returns: numeric
Rate of Change.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | no | 10 |
rsi
Signature: rsi(data, window=14)
Returns: numeric
Relative Strength Index.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | no | 14 |
rvi
Signature: rvi(open, high, low, close, length=10)
Returns: numeric
Relative Vigor Index (FE plot0): rolling sum of SWMA(close-open) / SWMA(high-low). FE: swmaCO[i]=(co[i-3]+2co[i-2]+2co[i-1]+co[i])/6 (NaN i<3); same for swmaHL. For i<length+2: NaN; else rviValues[i] = sum(swmaCO[j], j=i-length+1..i) / sum(swmaHL[j]). If sumHL==0, push 0 (FE).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | Series | yes | — |
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
length | int | no | 10 |
rvol
Signature: rvol(close, length=10)
Returns: numeric
Relative Volatility Index (Donald Dorsey) — FE relative-volatility-index plot0. FE: stddevArr = ta.stdev(close, length); change[i] = close[i]-close[i-1] (NaN at 0). upperInput[i] = chg<=0 ? 0 : stddev[i]; lowerInput[i] = chg>0 ? 0 : stddev[i]; upperArr = ta.ema(upperInput, 14); lowerArr = ta.ema(lowerInput, 14); rvi = upper/(upper+lower)*100 (0 when denom 0). Inner EMA length is hardcoded to 14.
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
length | int | no | 10 |
sma
Signature: sma(data, window)
Returns: numeric
Simple Moving Average.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | yes | — |
smi_ergodic
Signature: smi_ergodic(close, long_len=20, short_len=5, signal_len=5)
Returns: numeric
SMI Ergodic Indicator (FE formula, plot0 only; no *100). pc[0]=NaN, pc[i]=close[i]-close[i-1]. ds_pc = EMA(EMA(pc, long), short); ds_abs_pc = EMA(EMA(abs(pc), long), short). SMI = ds_pc / ds_abs_pc.
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
long_len | int | no | 20 |
short_len | int | no | 5 |
signal_len | int | no | 5 |
smi_ergodic_osc
Signature: smi_ergodic_osc(close, long_len=20, short_len=5, signal_len=5)
Returns: numeric
SMI Ergodic Oscillator (FE formula): smi - EMA(smi, signal_len).
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
long_len | int | no | 20 |
short_len | int | no | 5 |
signal_len | int | no | 5 |
smma
Signature: smma(data, length=14)
Returns: numeric
Smoothed Moving Average (same math as rma).
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
length | int | no | 14 |
stdev
Signature: stdev(data, window=20)
Returns: numeric
Population Standard Deviation (FE ta.stdev): sqrt(sum((x-mean)^2) / N).
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | no | 20 |
stoch
Signature: stoch(high, low, close, k=14, smooth_k=1, d=3)
Returns: tuple
Stochastic Oscillator — returns (k, d). Example: k_line, d_line = stoch(high, low, close, 14, 1, 3)
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
k | int | no | 14 |
smooth_k | int | no | 1 |
d | int | no | 3 |
stoch_d
Signature: stoch_d(high, low, close, k=14, smooth_k=1, d=3)
Returns: numeric
Stochastic %D (smoothed %K).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
k | int | no | 14 |
smooth_k | int | no | 1 |
d | int | no | 3 |
stoch_k
Signature: stoch_k(high, low, close, k=14, smooth_k=1, d=3)
Returns: numeric
Stochastic %K.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
k | int | no | 14 |
smooth_k | int | no | 1 |
d | int | no | 3 |
stoch_rsi
Signature: stoch_rsi(data, rsi_length=14, stoch_length=14, smooth_k=3, smooth_d=3)
Returns: numeric
Stochastic RSI K line (FE plot0): sma(stoch(rsi,rsi,rsi, lengthStoch), smoothK). Matches FE StochRSI.calculate: K = sma(stochRsi, smoothK), D = sma(K, smoothD). This function returns K (FE plot0). Warmup gates on non-NaN rsi values within the stoch window (FE ta.highest/lowest skip NaNs).
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
rsi_length | int | no | 14 |
stoch_length | int | no | 14 |
smooth_k | int | no | 3 |
smooth_d | int | no | 3 |
supertrend
Signature: supertrend(high, low, close, atr_period=10, factor=3.0)
Returns: numeric
SuperTrend (FE oakscriptjs ta.supertrend, wicks=false). source = (high+low)/2; atr = ta.atr(bars, atrPeriod). For each bar: upper = source + factoratr; lower = source - factoratr. Band carry uses PREVIOUS CLOSE (prevLowPrice=close[i-1], prevHighPrice=close[i-1]): lower = (lower>prevLower or close[i-1]<prevLower) ? lower : prevLower upper = (upper<prevUpper or close[i-1]>prevUpper) ? upper : prevUpper Direction: first non-NaN bar → 1 (down); if prevSt==prevUpper → dir=(close[i]>upper ? -1 : 1); else dir=(close[i]<lower ? 1 : -1). SuperTrend = dir==-1 ? lower : upper.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
atr_period | int | no | 10 |
factor | float | no | 3.0 |
tema
Signature: tema(data, window)
Returns: numeric
Triple Exponential Moving Average.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | yes | — |
trend_strength
Signature: trend_strength(close, length=14, ma_length=50)
Returns: numeric
Trend Strength Index (FE formula): Pearson correlation(close, bar_index, length). ma_length is kept for signature compatibility (FE's indicator ignores any MA smoothing; only length drives the rolling correlation window).
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
length | int | no | 14 |
ma_length | int | no | 50 |
trima
Signature: trima(data, window)
Returns: numeric
Triangular Moving Average.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | yes | — |
trix
Signature: trix(data, window=18)
Returns: numeric
TRIX oscillator (FE formula): 1e4 * change(ema3(log(close)), 1). ema3 = EMA(EMA(EMA(log(close), length), length), length) with FE-style seeded EMA. Then take 1-period difference and multiply by 10000.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | no | 18 |
tsi
Signature: tsi(close, long=25, short=13)
Returns: numeric
True Strength Index (FE formula). pc[0]=NaN, pc[i]=close[i]-close[i-1]. Double-smooth pc with EMA(long)->EMA(short) and similarly for abs(pc). TSI = 100 * ds_pc / ds_abs_pc.
| Parameter | Type | Required | Default |
|---|---|---|---|
close | Series | yes | — |
long | int | no | 25 |
short | int | no | 13 |
twap
Signature: twap(open, high, low, close, time)
Returns: numeric
TWAP (FE calculate83): daily-anchored cumulative mean of ohlc4. FE defaults: anchor='1D', src='ohlc4', offset=0. For each bar, if the UTC day changed vs previous bar, reset sum/count. Push cumulative mean (sum/count) for each bar; push NaN if no non-NaN values seen in the period.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | Series | yes | — |
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
time | Series | yes | — |
typprice
Signature: typprice(high, low, close)
Returns: numeric
Typical Price.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
ultimate_osc
Signature: ultimate_osc(high, low, close, length1=7, length2=14, length3=28)
Returns: numeric
Ultimate Oscillator (multi-timeframe momentum).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
length1 | int | no | 7 |
length2 | int | no | 14 |
length3 | int | no | 28 |
volume_delta
Signature: volume_delta(open, close, volume)
Returns: numeric
Volume Delta — signed volume based on close vs open direction.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | Series | yes | — |
close | Series | yes | — |
volume | Series | yes | — |
volume_osc
Signature: volume_osc(volume, short=5, long=10)
Returns: numeric
Volume Oscillator (FE formula): 100 * (ema(volume, short) - ema(volume, long)) / ema(volume, long). Uses FE-seeded EMAs; NaN when long-EMA unavailable or zero.
| Parameter | Type | Required | Default |
|---|---|---|---|
volume | Series | yes | — |
short | int | no | 5 |
long | int | no | 10 |
vortex
Signature: vortex(high, low, close, length=14)
Returns: tuple
Vortex Indicator — returns (plus, minus).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
length | int | no | 14 |
vortex_minus
Signature: vortex_minus(high, low, close, length=14)
Returns: numeric
Vortex negative line (VI-).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
length | int | no | 14 |
vortex_plus
Signature: vortex_plus(high, low, close, length=14)
Returns: numeric
Vortex positive line (VI+).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
length | int | no | 14 |
vwap
Signature: vwap(high, low, close, volume)
Returns: numeric
Volume Weighted Average Price over the entire series.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
volume | Series | yes | — |
vwma
Signature: vwma(data, volume, length=20)
Returns: numeric
Volume Weighted Moving Average over window.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
volume | Series | yes | — |
length | int | no | 20 |
wclprice
Signature: wclprice(high, low, close)
Returns: numeric
Weighted Close Price.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
williams_r
Signature: williams_r(high, low, close, window=14)
Returns: numeric
Williams %R momentum indicator (-100 to 0).
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
window | int | no | 14 |
wma
Signature: wma(data, window)
Returns: numeric
Weighted Moving Average.
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | yes | — |
woodies_cci
Signature: woodies_cci(high, low, close, length=14, turbo=6)
Returns: numeric
Woodies CCI (FE plot0, histogram) — classic CCI on CLOSE with given length. FE woodies-cci uses source = bars.map(b => b.close) (not HLC3) and plots three lines: plot0=CCI(close, cciLength) histogram; plot1=CCI(close, turboLength); plot2=CCI(close, cciLength). DSL returns plot0 (the histogram series). The turbo parameter is preserved for signature compatibility.
| Parameter | Type | Required | Default |
|---|---|---|---|
high | Series | yes | — |
low | Series | yes | — |
close | Series | yes | — |
length | int | no | 14 |
turbo | int | no | 6 |
zscore
Signature: zscore(data, window=20)
Returns: numeric
Rolling Z-score (standardized value).
| Parameter | Type | Required | Default |
|---|---|---|---|
data | Series | yes | — |
window | int | no | 20 |
Signal
cross
Signature: cross(series1, series2)
Returns: boolean
Detect when series1 crosses series2 in either direction.
| Parameter | Type | Required | Default |
|---|---|---|---|
series1 | Series | yes | — |
series2 | Series | yes | — |
crossover
Signature: crossover(series1, series2)
Returns: boolean
Detect when series1 crosses above series2.
| Parameter | Type | Required | Default |
|---|---|---|---|
series1 | any | yes | — |
series2 | any | yes | — |
crossunder
Signature: crossunder(series1, series2)
Returns: boolean
Detect when series1 crosses below series2.
| Parameter | Type | Required | Default |
|---|---|---|---|
series1 | any | yes | — |
series2 | any | yes | — |
Pattern
abandoned_baby
Signature: abandoned_baby(open, high, low, close)
Returns: numeric
Abandoned Baby: gap-down doji between two candles (bullish or bearish).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
advance_block
Signature: advance_block(open, high, low, close)
Returns: numeric
Advance Block: simplified bearish triple reversal.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
belt_hold
Signature: belt_hold(open, high, low, close)
Returns: numeric
Belt Hold: large body (>1.5x avg) with tiny shadow on the opening side.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
breakaway
Signature: breakaway(open, high, low, close)
Returns: numeric
Breakaway: simplified bullish triple reversal.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
closing_marubozu
Signature: closing_marubozu(open, high, low, close)
Returns: numeric
Closing Marubozu: no shadow on the closing side (bullish: no upper, bearish: no lower).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
concealing_baby_swallow
Signature: concealing_baby_swallow(open, high, low, close)
Returns: numeric
Concealing Baby Swallow: simplified bullish triple reversal.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
counterattack
Signature: counterattack(open, high, low, close)
Returns: numeric
Counterattack: opposite-color candles with same close.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
dark_cloud_cover
Signature: dark_cloud_cover(open, high, low, close)
Returns: numeric
Dark Cloud Cover: bullish candle -> bearish candle that closes below 50% of prev body.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
deliberation
Signature: deliberation(open, high, low, close)
Returns: numeric
Deliberation: simplified bearish triple reversal.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
doji
Signature: doji(open, high, low, close)
Returns: numeric
Doji: body < 5% of total range.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
dojistar
Signature: dojistar(open, high, low, close)
Returns: numeric
Doji Star: large candle followed by a doji with a gap.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
downside_tasuki_gap
Signature: downside_tasuki_gap(open, high, low, close)
Returns: numeric
Downside Tasuki Gap: bearish-side tasuki gap only.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
dragonfly_doji
Signature: dragonfly_doji(open, high, low, close)
Returns: numeric
Dragonfly Doji: doji with long lower shadow (>60% range) and tiny upper shadow (<10% range).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
engulfing
Signature: engulfing(open, high, low, close)
Returns: numeric
Engulfing: current candle body completely engulfs previous candle body.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
evening_doji_star
Signature: evening_doji_star(open, high, low, close)
Returns: numeric
Evening Doji Star: bullish -> doji -> bearish (closes below 50% of 1st body).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
evening_star
Signature: evening_star(open, high, low, close)
Returns: numeric
Evening Star: long bullish -> small body -> long bearish (closes below 50% of 1st body).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
falling_three_methods
Signature: falling_three_methods(open, high, low, close)
Returns: numeric
Falling Three Methods: simplified bearish triple reversal.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
gap_side_by_side_white
Signature: gap_side_by_side_white(open, high, low, close)
Returns: numeric
Gap Side By Side White: two bullish candles with similar opens after a gap.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
gravestone_doji
Signature: gravestone_doji(open, high, low, close)
Returns: numeric
Gravestone Doji: doji with long upper shadow (>60% range) and tiny lower shadow (<10% range).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
hammer
Signature: hammer(open, high, low, close)
Returns: numeric
Hammer: small body at top, lower shadow >= 2x body, upper shadow < 30% body.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
hanging_man
Signature: hanging_man(open, high, low, close)
Returns: numeric
Hanging Man: like hammer but bearish context (close < open).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
harami
Signature: harami(open, high, low, close)
Returns: numeric
Harami: current candle body is contained within previous candle body.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
harami_cross
Signature: harami_cross(open, high, low, close)
Returns: numeric
Harami Cross: large candle followed by a doji contained within its body.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
high_wave
Signature: high_wave(open, high, low, close)
Returns: numeric
High Wave: very small body (<15% range) with both long shadows (>30% range).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
homing_pigeon
Signature: homing_pigeon(open, high, low, close)
Returns: numeric
Homing Pigeon: two bearish candles, second contained within the first (bullish reversal).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
identical_three_crows
Signature: identical_three_crows(open, high, low, close)
Returns: numeric
Identical Three Crows: three bearish candles, each opening at previous close.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
in_neck
Signature: in_neck(open, high, low, close)
Returns: numeric
In Neck: bearish candle -> bullish candle that closes near the close of the first.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
inverted_hammer
Signature: inverted_hammer(open, high, low, close)
Returns: numeric
Inverted Hammer: small body at bottom, upper shadow >= 2x body, lower shadow < 30% body.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
kicking
Signature: kicking(open, high, low, close)
Returns: numeric
Kicking: two opposite marubozu candles with a gap.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
kicking_by_length
Signature: kicking_by_length(open, high, low, close)
Returns: numeric
Kicking By Length: alias for Kicking.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
ladder_bottom
Signature: ladder_bottom(open, high, low, close)
Returns: numeric
Ladder Bottom: simplified bullish triple reversal.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
long_legged_doji
Signature: long_legged_doji(open, high, low, close)
Returns: numeric
Long Legged Doji: doji with both shadows > 30% of range.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
marubozu
Signature: marubozu(open, high, low, close)
Returns: numeric
Marubozu: body > 95% of total range (almost no shadows).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
mat_hold
Signature: mat_hold(open, high, low, close)
Returns: numeric
Mat Hold: simplified bullish triple reversal.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
matching_high
Signature: matching_high(open, high, low, close)
Returns: numeric
Matching High: two bullish candles with same close (bearish reversal).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
matching_low
Signature: matching_low(open, high, low, close)
Returns: numeric
Matching Low: two bearish candles with same close (bullish reversal).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
meeting_lines
Signature: meeting_lines(open, high, low, close)
Returns: numeric
Meeting Lines: opposite-color candles with same close.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
morning_doji_star
Signature: morning_doji_star(open, high, low, close)
Returns: numeric
Morning Doji Star: bearish -> doji -> bullish (closes above 50% of 1st body).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
morning_star
Signature: morning_star(open, high, low, close)
Returns: numeric
Morning Star: long bearish -> small body -> long bullish (closes above 50% of 1st body).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
on_neck
Signature: on_neck(open, high, low, close)
Returns: numeric
On Neck: bearish candle -> bullish candle that closes near the low of the first.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
opening_marubozu
Signature: opening_marubozu(open, high, low, close)
Returns: numeric
Opening Marubozu: no shadow on the opening side (bullish: no lower, bearish: no upper).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
piercing
Signature: piercing(open, high, low, close)
Returns: numeric
Piercing Line: bearish candle -> bullish candle that closes above 50% of prev body.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
rickshaw_man
Signature: rickshaw_man(open, high, low, close)
Returns: numeric
Rickshaw Man: alias for Long Legged Doji.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
rising_three_methods
Signature: rising_three_methods(open, high, low, close)
Returns: numeric
Rising Three Methods: simplified bullish triple reversal.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
separating_lines
Signature: separating_lines(open, high, low, close)
Returns: numeric
Separating Lines: opposite-color candles with same open.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
shooting_star
Signature: shooting_star(open, high, low, close)
Returns: numeric
Shooting Star: like inverted hammer but bearish context (close < open).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
side_by_side_white_lines
Signature: side_by_side_white_lines(open, high, low, close)
Returns: numeric
Side By Side White Lines: alias for Gap Side By Side White.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
spinning_top
Signature: spinning_top(open, high, low, close)
Returns: numeric
Spinning Top: small body (<30% range) with both shadows > body.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
stalled_pattern
Signature: stalled_pattern(open, high, low, close)
Returns: numeric
Stalled Pattern: simplified bearish triple reversal.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
stick_sandwich
Signature: stick_sandwich(open, high, low, close)
Returns: numeric
Stick Sandwich: bearish-bullish-bearish with 1st and 3rd close at same level.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
tasuki_gap
Signature: tasuki_gap(open, high, low, close)
Returns: numeric
Tasuki Gap: two same-direction candles with gap, 3rd opposite fills the gap.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
three_black_crows
Signature: three_black_crows(open, high, low, close)
Returns: numeric
Three Black Crows: three consecutive bearish candles, each closing lower.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
three_inside
Signature: three_inside(open, high, low, close)
Returns: numeric
Three Inside: harami pattern confirmed by 3rd candle breaking out.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
three_inside_down
Signature: three_inside_down(open, high, low, close)
Returns: numeric
Three Inside Down: bullish -> bearish harami -> bearish close below 1st open.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
three_inside_up
Signature: three_inside_up(open, high, low, close)
Returns: numeric
Three Inside Up: bearish -> bullish harami -> bullish close above 1st open.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
three_line_strike
Signature: three_line_strike(open, high, low, close)
Returns: numeric
Three Line Strike: three same-direction candles + 4th opposite engulfs all three.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
three_outside
Signature: three_outside(open, high, low, close)
Returns: numeric
Three Outside: engulfing pattern confirmed by 3rd candle continuing.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
three_stars_in_south
Signature: three_stars_in_south(open, high, low, close)
Returns: numeric
Three Stars in South: simplified bullish triple reversal.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
three_white_soldiers
Signature: three_white_soldiers(open, high, low, close)
Returns: numeric
Three White Soldiers: three consecutive bullish candles, each closing higher.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
thrusting
Signature: thrusting(open, high, low, close)
Returns: numeric
Thrusting: bearish candle -> bullish candle that closes above prev close but below midpoint.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
tristar
Signature: tristar(open, high, low, close)
Returns: numeric
Tri-Star: three consecutive dojis with middle one gapping.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
tweezer_bottom
Signature: tweezer_bottom(open, high, low, close)
Returns: numeric
Tweezer Bottom: two candles with same low, first bearish, second bullish.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
tweezer_top
Signature: tweezer_top(open, high, low, close)
Returns: numeric
Tweezer Top: two candles with same high, first bullish, second bearish.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
two_crows
Signature: two_crows(open, high, low, close)
Returns: numeric
Two Crows: bullish -> bearish gap up -> bearish closing below 1st close.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
unique_three_river
Signature: unique_three_river(open, high, low, close)
Returns: numeric
Unique Three River: simplified bullish triple reversal.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
up_down_gap_three_methods
Signature: up_down_gap_three_methods(open, high, low, close)
Returns: numeric
Up/Down Gap Three Methods: alias for Tasuki Gap.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
upside_gap_two_crows
Signature: upside_gap_two_crows(open, high, low, close)
Returns: numeric
Upside Gap Two Crows: bullish -> bearish gap up -> bearish engulfing (bearish).
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
upside_tasuki_gap
Signature: upside_tasuki_gap(open, high, low, close)
Returns: numeric
Upside Tasuki Gap: bullish-side tasuki gap only.
| Parameter | Type | Required | Default |
|---|---|---|---|
open | pl.Series | yes | — |
high | pl.Series | yes | — |
low | pl.Series | yes | — |
close | pl.Series | yes | — |
Timeseries
adf_statistic
Signature: adf_statistic(x, d=60)
Returns: numeric
Rolling Augmented Dickey-Fuller test statistic. Tests for stationarity. More negative = more stationary. Critical values: -3.43 (1%), -2.86 (5%), -2.57 (10%) Args: x: Time series to test d: Rolling window size Returns: ADF test statistic series Usage: adf = adf_statistic(spread, 60) is_stationary = adf < -2.86 # 5% significance
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | no | 60 |
half_life
Signature: half_life(x, d=60)
Returns: numeric
Rolling half-life of mean reversion. Estimates how quickly a series reverts to its mean using AR(1) model. Half-life = -ln(2) / ln(rho) where rho is AR(1) coefficient. Args: x: Time series (typically a spread or z-score) d: Rolling window size Returns: Half-life in number of periods (lower = faster mean reversion) Usage: hl = half_life(spread, 60) # Good pair if hl is between 1-30 days
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | no | 60 |
hurst_exponent
Signature: hurst_exponent(x, d=100, max_lag=20)
Returns: numeric
Rolling Hurst Exponent for regime detection. H < 0.5: Mean-reverting (good for pair trading) H = 0.5: Random walk (no predictability) H > 0.5: Trending (momentum strategies) Args: x: Time series to analyze d: Rolling window size max_lag: Maximum lag for R/S calculation Returns: Hurst exponent series Usage: h = hurst_exponent(spread, 100) is_mean_reverting = h < 0.5
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | no | 100 |
max_lag | int | no | 20 |
kalman_filter
Signature: kalman_filter(y, x, delta=0.0001, ve=0.001)
Returns: tuple
Kalman Filter - Returns (beta, alpha, spread) tuple. Full Kalman filter output for pair trading. Usage: beta, alpha, spread = kalman_filter(price_y, price_x)
| Parameter | Type | Required | Default |
|---|---|---|---|
y | Series | yes | — |
x | Series | yes | — |
delta | float | no | 0.0001 |
ve | float | no | 0.001 |
kalman_hedge_ratio
Signature: kalman_hedge_ratio(y, x, delta=0.0001, ve=0.001)
Returns: numeric
Kalman Filter for adaptive hedge ratio estimation. Implements online Kalman filter to estimate time-varying hedge ratio (beta). Superior to OLS for non-stationary relationships. Args: y: Dependent variable (e.g., asset Y price) x: Independent variable (e.g., asset X price) delta: Process variance - controls how fast beta can change (default: 1e-4) ve: Measurement variance - observation noise (default: 1e-3) Returns: Time-varying hedge ratio (beta) series Usage: beta = kalman_hedge_ratio(price_y, price_x) spread = price_y - beta * price_x
| Parameter | Type | Required | Default |
|---|---|---|---|
y | Series | yes | — |
x | Series | yes | — |
delta | float | no | 0.0001 |
ve | float | no | 0.001 |
rolling_ols_beta
Signature: rolling_ols_beta(y, x, d)
Returns: numeric
Rolling OLS hedge ratio (beta). Standard rolling regression beta. Use kalman_hedge_ratio for adaptive estimation that handles regime changes better. Args: y: Dependent variable x: Independent variable d: Rolling window Returns: Rolling beta series
| Parameter | Type | Required | Default |
|---|---|---|---|
y | Series | yes | — |
x | Series | yes | — |
d | int | yes | — |
spread
Signature: spread(y, x, beta)
Returns: numeric
Calculate spread given hedge ratio. Args: y: Dependent asset price x: Independent asset price beta: Hedge ratio (can be from OLS or Kalman) Returns: Spread series (y - beta * x) Usage: beta = kalman_hedge_ratio(price_y, price_x) sprd = spread(price_y, price_x, beta) zscore = ts_zscore(sprd, 20)
| Parameter | Type | Required | Default |
|---|---|---|---|
y | Series | yes | — |
x | Series | yes | — |
beta | Series | yes | — |
spread_zscore
Signature: spread_zscore(y, x, d=60)
Returns: numeric
Z-score of Kalman filter spread. Combines Kalman filter hedge ratio estimation with z-score normalization. Useful for generating pair trading signals directly. Args: y: Dependent asset price x: Independent asset price d: Window for z-score calculation Returns: Z-score of spread Usage: zscore = spread_zscore(price_y, price_x, 60) long_signal = zscore < -2 short_signal = zscore > 2
| Parameter | Type | Required | Default |
|---|---|---|---|
y | Series | yes | — |
x | Series | yes | — |
d | int | no | 60 |
ts_arg_max
Signature: ts_arg_max(x, d)
Returns: numeric
Returns the relative index of the max value in the time series for the past d days
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
ts_arg_min
Signature: ts_arg_min(x, d)
Returns: numeric
Returns the relative index of the min value in the time series for the past d days
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
ts_av_diff
Signature: ts_av_diff(x, d)
Returns: numeric
Returns x - tsmean(x, d)
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
ts_backfill
Signature: ts_backfill(x, lookback=None, k=1, ignore=None)
Returns: numeric
Backfill is the process of replacing the NAN values by a meaningful value (i.e., a first non-NaN value)
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
lookback | int | no | None |
k | int | no | 1 |
ignore | float | no | None |
ts_corr
Signature: ts_corr(x, y, d)
Returns: numeric
Returns correlation of x and y for the past d days. OPTIMIZED: Uses numpy vectorized operations for O(n) complexity.
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
y | Series | yes | — |
d | int | yes | — |
ts_count_nans
Signature: ts_count_nans(x, d)
Returns: numeric
Returns the number of NaN values in x for the past d days
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
ts_covariance
Signature: ts_covariance(y, x, d)
Returns: numeric
Returns covariance of y and x for the past d days
| Parameter | Type | Required | Default |
|---|---|---|---|
y | Series | yes | — |
x | Series | yes | — |
d | int | yes | — |
ts_decay_linear
Signature: ts_decay_linear(x, d, dense=False)
Returns: numeric
Returns the linear decay on x for the past d days
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
dense | bool | no | False |
ts_delay
Signature: ts_delay(x, d)
Returns: numeric
Returns x value d bars ago
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
ts_delta
Signature: ts_delta(x, d)
Returns: numeric
Returns x - ts_delay(x, d)
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
ts_max
Signature: ts_max(x, d)
Returns: numeric
Returns maximum value of x for the past d days
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
ts_mean
Signature: ts_mean(x, d)
Returns: numeric
Returns average value of x for the past d days.
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
ts_min
Signature: ts_min(x, d)
Returns: numeric
Returns minimum value of x for the past d days
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
ts_product
Signature: ts_product(x, d)
Returns: numeric
Returns product of x for the past d days
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
ts_rank
Signature: ts_rank(x, d, constant=0)
Returns: numeric
Rank the values of x for each instrument over the past d days, then return the rank of the current value + constant.
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
constant | float | no | 0 |
ts_regintercept
Signature: ts_regintercept(y, x, d)
Returns: numeric
Returns rolling regression intercept (alpha) of y on x.
| Parameter | Type | Required | Default |
|---|---|---|---|
y | Series | yes | — |
x | Series | yes | — |
d | int | yes | — |
ts_regression
Signature: ts_regression(y, x, d, lag=0, rettype=0)
Returns: numeric
Returns various parameters related to regression function. OPTIMIZED: Uses numpy vectorized operations with stride_tricks for O(n) complexity.
| Parameter | Type | Required | Default |
|---|---|---|---|
y | Series | yes | — |
x | Series | yes | — |
d | int | yes | — |
lag | int | no | 0 |
rettype | Literal[0, 1, 2] | no | 0 |
ts_regression_resid
Signature: ts_regression_resid(y, x, d)
Returns: numeric
Returns rolling regression residual (spread = y - beta*x - alpha).
| Parameter | Type | Required | Default |
|---|---|---|---|
y | Series | yes | — |
x | Series | yes | — |
d | int | yes | — |
ts_regslope
Signature: ts_regslope(y, x, d)
Returns: numeric
Returns rolling regression slope (beta/hedge ratio) of y on x.
| Parameter | Type | Required | Default |
|---|---|---|---|
y | Series | yes | — |
x | Series | yes | — |
d | int | yes | — |
ts_scale
Signature: ts_scale(x, d, constant=0)
Returns: numeric
Returns (x - ts_min(x, d)) / (ts_max(x, d) - ts_min(x, d)) + constant
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
constant | float | no | 0 |
ts_std_dev
Signature: ts_std_dev(x, d)
Returns: numeric
Returns standard deviation of x for the past d days
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
ts_sum
Signature: ts_sum(x, d)
Returns: numeric
Sum values of x for the past d days.
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
ts_zscore
Signature: ts_zscore(x, d)
Returns: numeric
Z-score: (x - tsmean(x,d)) / tsstddev(x,d)
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Series | yes | — |
d | int | yes | — |
Arithmetic
abs
Signature: abs(x)
Returns: numeric
Absolute value of x
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Union[float, int, Series] | yes | — |
add
Signature: add(x, y, filter=False)
Returns: numeric
Add all inputs (at least 2 inputs required). If filter = true, filter all input NaN to 0 before adding
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Union[float, int, Series] | yes | — |
y | Union[float, int, Series] | yes | — |
filter | bool | no | False |
divide
Signature: divide(x, y)
Returns: numeric
Divide x by y
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Union[float, int, Series] | yes | — |
y | Union[float, int, Series] | yes | — |
inverse
Signature: inverse(x)
Returns: numeric
Inverse of x
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Union[float, int, Series] | yes | — |
log
Signature: log(x)
Returns: numeric
Natural logarithm of x
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Union[float, int, Series] | yes | — |
max
Signature: max(x, y, *args)
Returns: numeric
Maximum value of all inputs. At least 2 inputs are required
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Union[float, int, Series] | yes | — |
y | Union[float, int, Series] | yes | — |
*args | Union[float, int, Series] | no | — |
min
Signature: min(x, y, *args)
Returns: numeric
Minimum value of all inputs. At least 2 inputs are required
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Union[float, int, Series] | yes | — |
y | Union[float, int, Series] | yes | — |
*args | Union[float, int, Series] | no | — |
multiply
Signature: multiply(x, y, *args, filter=False)
Returns: numeric
Multiply all inputs. At least 2 inputs are required. Filter sets the NaN values to 1
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Union[float, int, Series] | yes | — |
y | Union[float, int, Series] | yes | — |
*args | Union[float, int, Series] | no | — |
filter | bool | no | False |
power
Signature: power(x, y)
Returns: numeric
x raised to the power of y
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Union[float, int, Series] | yes | — |
y | Union[float, int, Series] | yes | — |
reverse
Signature: reverse(x)
Returns: numeric
Reverse of x
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Union[float, int, Series] | yes | — |
sign
Signature: sign(x)
Returns: numeric
Sign of x
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Union[float, int, Series] | yes | — |
signed_power
Signature: signed_power(x, y)
Returns: numeric
x raised to the power of y such that final result preserves sign of x
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Union[float, int, Series] | yes | — |
y | Union[float, int, Series] | yes | — |
subtract
Signature: subtract(x, y, filter=False)
Returns: numeric
Subtract y from x. If filter = true, filter all input NaN to 0 before subtracting
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Union[float, int, Series] | yes | — |
y | Union[float, int, Series] | yes | — |
filter | bool | no | False |
Logical
and_operator
Signature: and_operator(input1, input2)
Returns: boolean
Logical AND operator, returns true if both operands are true and returns false otherwise
| Parameter | Type | Required | Default |
|---|---|---|---|
input1 | Union[float, int, Series, bool] | yes | — |
input2 | Union[float, int, Series, bool] | yes | — |
if_else
Signature: if_else(condition, a, b)
Returns: boolean
If condition is true, return a, else return b
| Parameter | Type | Required | Default |
|---|---|---|---|
condition | Series | yes | — |
a | any | yes | — |
b | any | yes | — |
is_nan
Signature: is_nan(a)
Returns: boolean
Return true if a is nan
| Parameter | Type | Required | Default |
|---|---|---|---|
a | Series | yes | — |
is_not_nan
Signature: is_not_nan(a)
Returns: boolean
Return true if a is not nan
| Parameter | Type | Required | Default |
|---|---|---|---|
a | Series | yes | — |
logical_not
Signature: logical_not(a)
Returns: boolean
Return true if a is false
| Parameter | Type | Required | Default |
|---|---|---|---|
a | Series | yes | — |
not_operator
Signature: not_operator(x)
Returns: boolean
Returns the logical negation of x. If x is true (1), it returns false (0), and if input is false (0), it returns true (1).
| Parameter | Type | Required | Default |
|---|---|---|---|
x | Union[float, int, Series, bool] | yes | — |
or_operator
Signature: or_operator(input1, input2)
Returns: boolean
Logical OR operator returns true if either or both inputs are true and returns false otherwise
| Parameter | Type | Required | Default |
|---|---|---|---|
input1 | Union[float, int, Series, bool] | yes | — |
input2 | Union[float, int, Series, bool] | yes | — |
Wallet
wallet_filled
Signature: wallet_filled(address, coin=None)
Returns: boolean
Check if a tracked wallet has a new fill.
| Parameter | Type | Required | Default |
|---|---|---|---|
address | str | yes | — |
coin | str | no | None |
wallet_price
Signature: wallet_price(address, coin=None)
Returns: numeric
Get the price of the latest fill.
| Parameter | Type | Required | Default |
|---|---|---|---|
address | str | yes | — |
coin | str | no | None |
wallet_side
Signature: wallet_side(address, coin=None)
Returns: string
Get the side of the latest fill (BUY/SELL).
| Parameter | Type | Required | Default |
|---|---|---|---|
address | str | yes | — |
coin | str | no | None |
wallet_size
Signature: wallet_size(address, coin=None)
Returns: numeric
Get the size of the latest fill.
| Parameter | Type | Required | Default |
|---|---|---|---|
address | str | yes | — |
coin | str | no | None |