Expression Operators

Where they can be used: factor expressions in data-processing nodes, condition expressions in strategy nodes, and label definitions for AI models

1. Basic operators

Element-wise calculations performed independently at each data point

OperatorSyntaxDescriptionReturn typeExample
absabs(x)Absolute valueNumberabs(close - open)
loglog(x)Natural logarithmNumberlog(volume)
expexp(x)Exponential function e^xNumberexp(returns)
sqrtsqrt(x)Square rootNumbersqrt(variance)
signsign(x)Sign function (returns -1, 0, or 1)-1/0/1sign(returns)
roundround(x, decimals)Rounds to the specified number of decimal placesNumberround(price, 2)
maxmax(x, y)Element-wise maximumNumbermax(open, close)
minmin(x, y)Element-wise minimumNumbermin(open, close)
meanmean([cols])Element-wise mean across multiple columnsNumbermean([open, high, low, close])
ifif(cond, x, y)Conditional selectionx or yif(close > open, 1, -1)
clipclip(x, lower, upper)Clips values to [lower, upper]Numberclip(returns, -0.1, 0.1)
qclipqclip(x, q)Symmetrically clips values to the [q, 1-q] quantilesNumberqclip(returns, 0.01)

2. Time-series operators

Rolling-window calculations over time, grouped by instrument

OperatorSyntaxDescriptionReturn typeExample
shiftshift(x, n)Shifts by n periods (n > 0 retrieves historical values)Numbershift(close, 1)
deltadelta(x, n)n-period difference: x - shift(x, n)Numberdelta(close, 1)
pctpct(x, n)n-period rate of change: delta(x,n) / shift(x,n)Numberpct(close, 1)
argmaxargmax(x, n)Position of the maximum over n periods (1–n)Integerargmax(high, 20)
argminargmin(x, n)Position of the minimum over n periods (1–n)Integerargmin(low, 20)
t_meant_mean(x, n)n-period moving averageNumbert_mean(close, 20)
t_sumt_sum(x, n)n-period rolling sumNumbert_sum(volume, 5)
t_maxt_max(x, n)n-period maximumNumbert_max(high, 20)
t_mint_min(x, n)n-period minimumNumbert_min(low, 20)
t_stdt_std(x, n)n-period standard deviationNumbert_std(returns, 20)
t_vart_var(x, n)n-period varianceNumbert_var(returns, 20)
t_prodt_prod(x, n)n-period rolling productNumbert_prod(1 + returns, 20)
t_mediant_median(x, n)n-period medianNumbert_median(close, 20)
t_quantilet_quantile(x, n, q)q quantile over n periodsNumbert_quantile(close, 20, 0.75)
t_skewt_skew(x, n)n-period skewnessNumbert_skew(returns, 20)
t_kurtt_kurt(x, n)n-period kurtosisNumbert_kurt(returns, 20)
t_rankt_rank(x, n)Rank within n periods (maximum = 1)Integert_rank(close, 20)
t_pctrankt_pctrank(x, n)Percentile rank within n periods (0–1)Numbert_pctrank(close, 20)
t_countt_count(cond, n)Number of periods for which the condition is trueIntegert_count(close > open, 20)
t_allt_all(cond, n)Whether the condition is true for every periodBooleant_all(close > ma20, 5)
t_anyt_any(cond, n)Whether the condition is true in any periodBooleant_any(volume > avg_vol * 2, 5)
t_corrt_corr(x, y, n)n-period rolling correlationNumbert_corr(close, volume, 20)
t_covt_cov(x, y, n)n-period rolling covarianceNumbert_cov(returns, market_returns, 60)
t_betat_beta(y, x, n)n-period regression slope βNumbert_beta(returns, market_returns, 60)
t_alphat_alpha(y, x, n)n-period regression intercept αNumbert_alpha(returns, market_returns, 60)
t_residualt_residual(y, x, n)n-period regression residualNumbert_residual(returns, market_returns, 60)
t_zscoret_zscore(x, n)n-period time-series Z-score normalizationNumbert_zscore(close, 20)
t_scalet_scale(x, n)n-period time-series min-max normalization to [0,1]Numbert_scale(rsi, 20)

3. Cross-sectional operators

Calculations across all instruments, grouped by timestamp

OperatorSyntaxDescriptionReturn typeExample
c_meanc_mean(x)Cross-sectional meanNumberc_mean(returns)
c_sumc_sum(x)Cross-sectional sumNumberc_sum(volume)
c_maxc_max(x)Cross-sectional maximumNumberc_max(returns)
c_minc_min(x)Cross-sectional minimumNumberc_min(returns)
c_stdc_std(x)Cross-sectional standard deviationNumberc_std(returns)
c_medianc_median(x)Cross-sectional medianNumberc_median(pe_ratio)
c_rankc_rank(x)Cross-sectional rank (maximum = 1)Integerc_rank(returns)
c_pctrankc_pctrank(x)Cross-sectional percentile rank (0–1)Numberc_pctrank(momentum)
c_percentilec_percentile(x, q)Cross-sectional quantile valueNumberc_percentile(volume, 0.9)
c_topc_top(x, n)Marks the top N values in the cross sectionBooleanc_top(momentum, 10)
c_bottomc_bottom(x, n)Marks the bottom N values in the cross sectionBooleanc_bottom(momentum, 10)
c_zscorec_zscore(x)Cross-sectional Z-score normalizationNumberc_zscore(pe_ratio)
c_scalec_scale(x)Cross-sectional min-max normalization to [0,1]Numberc_scale(volume)
c_mad_zscorec_mad_zscore(x)Cross-sectional MAD Z-score (robust normalization)Numberc_mad_zscore(returns)
c_clipc_clip(x, lower, upper)Clips values to a specified interval within the cross sectionNumberc_clip(zscore, -3, 3)
c_qclipc_qclip(x, q)Quantile clipping within the cross sectionNumberc_qclip(returns, 0.01)
c_residualc_residual(y, x)Cross-sectional regression residual (neutralization)Numberc_residual(returns, market_cap)
c_absunitc_absunit(x, a?)Cross-sectional absolute-value normalizationNumberc_absunit(alpha)

4. Technical indicators

Classic technical-analysis indicators calculated separately for each instrument

OperatorSyntaxDescriptionReturn typeExample
ta_mata_ma(x, n)Simple Moving Average (SMA)Numberta_ma(close, 20)
ta_emata_ema(x, n)Exponential Moving Average (EMA)Numberta_ema(close, 12)
ta_wmata_wma(x, n)Weighted Moving Average (WMA)Numberta_wma(close, 20)
ta_rsita_rsi(x, n)Relative Strength Index (RSI)0-100ta_rsi(close, 14)
ta_rocta_roc(x, n)Rate of Change (ROC)Numberta_roc(close, 10)
ta_momta_mom(x, n)MomentumNumberta_mom(close, 10)
ta_ccita_cci(high, low, close, n)Commodity Channel Index (CCI)Numberta_cci(high, low, close, 20)
ta_willrta_willr(high, low, close, n)Williams %RNumberta_willr(high, low, close, 14)
ta_mfita_mfi(high, low, close, volume, n)Money Flow Index (MFI)0-100ta_mfi(high, low, close, volume, 14)
ta_biasta_bias(x, n)Bias ratio (BIAS)Numberta_bias(close, 20)
ta_ultimateta_ultimate(high, low, close, n1, n2, n3)Ultimate OscillatorNumberta_ultimate(high, low, close, 7, 14, 28)
ta_atrta_atr(high, low, close, n)Average True Range (ATR)Numberta_atr(high, low, close, 14)
ta_natrta_natr(high, low, close, n)Normalized Average True Range (NATR)Percentageta_natr(high, low, close, 14)
ta_bbands_upperta_bbands_upper(x, n, k?)Upper Bollinger BandNumberta_bbands_upper(close, 20, 2)
ta_bbands_midta_bbands_mid(x, n)Middle Bollinger Band (the moving average)Numberta_bbands_mid(close, 20)
ta_bbands_lowerta_bbands_lower(x, n, k?)Lower Bollinger BandNumberta_bbands_lower(close, 20, 2)
ta_bbands_widthta_bbands_width(x, n, k?)Bollinger Band widthNumberta_bbands_width(close, 20, 2)
ta_kc_upperta_kc_upper(high, low, close, n, k?)Upper Keltner ChannelNumberta_kc_upper(high, low, close, 20, 2)
ta_kc_lowerta_kc_lower(high, low, close, n, k?)Lower Keltner ChannelNumberta_kc_lower(high, low, close, 20, 2)
ta_obvta_obv(close, volume)On-Balance Volume (OBV)Numberta_obv(close, volume)
ta_cmfta_cmf(high, low, close, volume, n)Chaikin Money Flow (CMF)Numberta_cmf(high, low, close, volume, 20)
ta_adoscta_adosc(high, low, close, volume, fast, slow)Chaikin A/D OscillatorNumberta_adosc(high, low, close, volume, 3, 10)
ta_vwmata_vwma(close, volume, n)Volume-Weighted Moving Average (VWMA)Numberta_vwma(close, volume, 20)
ta_adxta_adx(high, low, close, n)Average Directional Index (ADX)Numberta_adx(high, low, close, 14)
ta_dmi_plusta_dmi_plus(high, low, close, n)Positive Directional Indicator (+DI)Numberta_dmi_plus(high, low, close, 14)
ta_dmi_minusta_dmi_minus(high, low, close, n)Negative Directional Indicator (-DI)Numberta_dmi_minus(high, low, close, 14)
ta_aroon_upta_aroon_up(high, low, n)Aroon UpNumberta_aroon_up(high, low, 25)
ta_aroon_downta_aroon_down(high, low, n)Aroon DownNumberta_aroon_down(high, low, 25)
ta_macd_difta_macd_dif(x, fast, slow)MACD DIF line (fast line minus slow line)Numberta_macd_dif(close, 12, 26)
ta_macd_deata_macd_dea(x, fast, slow, signal)MACD DEA line (EMA of DIF)Numberta_macd_dea(close, 12, 26, 9)
ta_macd_histta_macd_hist(x, fast, slow, signal)MACD histogram (DIF minus DEA)Numberta_macd_hist(close, 12, 26, 9)
ta_kdj_kta_kdj_k(high, low, close, n, k_smooth)K line of the KDJ indicatorNumberta_kdj_k(high, low, close, 9, 3)
ta_kdj_dta_kdj_d(high, low, close, n, k_smooth, d_smooth)D line of the KDJ indicatorNumberta_kdj_d(high, low, close, 9, 3, 3)
ta_kdj_jta_kdj_j(high, low, close, n, k_smooth, d_smooth)J line of the KDJ indicatorNumberta_kdj_j(high, low, close, 9, 3, 3)
ta_stoch_kta_stoch_k(high, low, close, n)Stochastic %K lineNumberta_stoch_k(high, low, close, 14)
ta_stoch_dta_stoch_d(high, low, close, n, d_smooth)Stochastic %D lineNumberta_stoch_d(high, low, close, 14, 3)
ta_cross_overta_cross_over(x, y)Crossover signal (x crosses y from below)Booleanta_cross_over(ma5, ma20)
ta_cross_underta_cross_under(x, y)Crossunder signal (x crosses y from above)Booleanta_cross_under(ma5, ma20)
ta_breakout_highta_breakout_high(high, n)Signal when price breaks above the N-period highBooleanta_breakout_high(high, 20)
ta_breakout_lowta_breakout_low(low, n)Signal when price breaks below the N-period lowBooleanta_breakout_low(low, 20)

5. Candlestick patterns

Recognition of classic candlestick patterns

OperatorSyntaxDescriptionReturn typeExample
ta_marubozu_bullta_marubozu_bull(open, close, high, low)Bullish marubozuBooleanta_marubozu_bull(open, close, high, low)
ta_marubozu_bearta_marubozu_bear(open, close, high, low)Bearish marubozuBooleanta_marubozu_bear(open, close, high, low)
ta_dojita_doji(open, close, high, low)DojiBooleanta_doji(open, close, high, low)
ta_pin_bar_longta_pin_bar_long(open, close, high, low)Bullish pin bar (long lower wick)Booleanta_pin_bar_long(open, close, high, low)
ta_pin_bar_shortta_pin_bar_short(open, close, high, low)Bearish pin bar (long upper wick)Booleanta_pin_bar_short(open, close, high, low)
ta_inside_bar_bullta_inside_bar_bull(high, low, close)Bullish inside barBooleanta_inside_bar_bull(high, low, close)
ta_inside_bar_bearta_inside_bar_bear(high, low, close)Bearish inside barBooleanta_inside_bar_bear(high, low, close)
ta_engulfing_bullta_engulfing_bull(open, close)Bullish engulfing patternBooleanta_engulfing_bull(open, close)
ta_engulfing_bearta_engulfing_bear(open, close)Bearish engulfing patternBooleanta_engulfing_bear(open, close)
ta_three_risingta_three_rising(close)Three consecutive rising closesBooleanta_three_rising(close)
ta_three_fallingta_three_falling(close)Three consecutive falling closesBooleanta_three_falling(close)
ta_hammerta_hammer(open, close, high, low)HammerBooleanta_hammer(open, close, high, low)
ta_shooting_starta_shooting_star(open, close, high, low)Shooting starBooleanta_shooting_star(open, close, high, low)
ta_morning_starta_morning_star(open, close, high, low)Morning starBooleanta_morning_star(open, close, high, low)
ta_evening_starta_evening_star(open, close, high, low)Evening starBooleanta_evening_star(open, close, high, low)
ta_top_divergenceta_top_divergence(price, indicator, n)Bearish divergence signalBooleanta_top_divergence(close, rsi, 20)
ta_bottom_divergenceta_bottom_divergence(price, indicator, n)Bullish divergence signalBooleanta_bottom_divergence(close, rsi, 20)
    BeeQuant - AI Quantitative Trading Platform