Hey-LiSA is in development phase and pre-alpha. These docs are still in progress and not complete yet.

Conditions and expressions

Conditions describe when a rule, branch, or IF path should run. Expressions describe numeric values that conditions and actions can reuse.

This page lists the condition and expression features currently implemented.

Currently implemented condition forms

Comparison conditions

{
  "name": "Cash is available",
  "left": "get('cash')",
  "op": ">=",
  "right": 50
}

Supported comparison operators are >, >=, <, <=, and ==.

Trading position conditions

Trading rules use position_state() to read the current position:

{
  "name": "Position is flat",
  "left": "position_state()",
  "op": "==",
  "right": "flat"
}

The supported position states are "flat", "long", and "short". Position-state conditions use equality and are available only to Trading strategies.

Grouped conditions

DCA strategies can use logic: "all" for AND-style groups and logic: "any" for OR-style groups. Trading rule conditions are ANDed. Position-bound exit_conditions use ordered named groups: every condition in one group must pass, and the first matching group is selected.

{
  "name": "Value zone is active",
  "logic": "all",
  "conditions": [
    { "name": "BTC is below MA365", "left": "price()", "op": "<", "right": "ma(365)" },
    { "name": "Cash is available", "left": "get('cash')", "op": ">", "right": 0 }
  ]
}

Tool-form conditions exist in the schema, but there are no supported public condition tools today.

Currently implemented expressions

In DCA strategies, expression strings are supported in condition operands, cashflow.amount, buy and sell sizing amounts, and set.values. Trading numeric rule conditions, position-bound exit conditions, and entry protection distances support price(), declared technical indicator functions, and time(...).

Allowed expression syntax:

  • numbers
  • +, -, *, /
  • parentheses
  • allowlisted function calls

Bare names, attributes, indexing, keyword arguments, and unknown calls are rejected by validation.

Currently implemented builtin functions

FunctionDescription
price()Current completed BTC close.
price(offset)BTC close from offset genuine strategy candles before the current candle.
ma(period[, offset])Full-window moving average of strategy-timeframe BTC closes.
ma(period, "4h"[, offset])Full-window 4h moving average.
ma(period, "1w"[, offset])Full-window weekly moving average resampled into UTC Monday weeks.
highest_close(period[, offset])Highest BTC close over a rolling candle window.
ath([offset])Highest BTC close from the earliest available local candle through the selected current or historical candle.
pi_cycle_ratio([offset])Pi Cycle ratio: MA111 / (2 * MA350).
pi_cycle_top_signal([offset])1 on the selected Pi Cycle Top crossover candle, otherwise 0.
rsi(period[, offset])Relative Strength Index using Wilder smoothing.
atr(period[, offset])Average True Range using a complete initial window and Wilder smoothing.
supertrend(period, factor[, offset])Supertrend line using Wilder ATR.
supertrend_bullish(period, factor[, offset])1 when Supertrend is bullish, otherwise 0.
supertrend_bearish(period, factor[, offset])1 when Supertrend is bearish, otherwise 0.
donchian(period, component[, offset])Donchian channel component. component is "lower" or "upper".
bollinger_bands(period, stddev, component[, offset])Bollinger Band component: "upper", "middle", or "lower".
macd(fast_period, slow_period, signal_period, component[, offset])MACD component: "line", "signal", or "histogram".
stochastic(k_period, smooth_period, d_period, component[, offset])Stochastic oscillator component: "k" or "d".
adx(period[, offset])Average Directional Index.
plus_di(period[, offset])Positive directional indicator.
minus_di(period[, offset])Negative directional indicator.
parabolic_sar(acceleration, maximum[, offset])Parabolic SAR value.
cci(period[, offset])Commodity Channel Index.
williams_r(period[, offset])Williams Percent Range.
ichimoku(tenkan_period, kijun_period, senkou_span_b_period, component[, offset])Ichimoku component: "tenkan", "kijun", "senkou_a", "senkou_b", or "chikou".
time(field, timezone[, offset])Calendar accessor for the selected candle open time.
series(id[, offset])Reads a declared daily external series at the selected candle.
get(name)Reads protected context values or strategy variables.

Supported time(...) fields are day_of_month, month, year, day_of_week, hour, and minute. day_of_week uses Monday as 0 through Sunday as 6.

Indicator calculation parameters are always explicit. atr(14) is valid and atr() is not. Every indicator function accepts one registry-defined optional trailing offset. An omitted offset means the current completed signal candle; a positive integer means that many genuine strategy candles back. price, time, and DCA series reads follow the same convention. Zero, negative, and future offsets are rejected.

Technical indicator functions require matching declarations in indicators. DCA external data reads use series(id) and require matching declarations in external_series. Trading supports time(...); get(...) and series(...) are not part of the current Trading contract.

position_state() is a Trading condition read, not a numeric expression function.