Language reference
Indicators, conditions, operators, risk, schedule and built-ins.
Indicators
Declare what you measure. Each line creates a variable you can reference in conditions:
indicators {
rsi = RSI(14)
ema_fast = EMA(9)
ema_slow = EMA(21)
atr = ATR(14)
vwap = VWAP()
}
| Indicator | Args | Returns | Best for |
|---|---|---|---|
RSI(period) | period (14) | 0–100 | overbought/oversold |
EMA(period) | 9, 21, 50… | price level | trend |
SMA(period) | period | price level | baseline |
ADX(period) | period (14) | 0–100 | trend strength |
ATR(period) | period (14) | price units | volatility |
VWAP() | — | price level | fair value |
MACD(f, s, sig) | 12, 26, 9 | MACD line | momentum |
Bollinger(p, std) | 20, 2 | {lower, upper, pct_b} | range/breakout |
Indicators are always available by their default name (e.g.
rsi, adx) even without declaring them. Declaring just gives you a custom alias.
Conditions
Entry conditions (AND)
Every condition must evaluate to true:
entry when {
ema_fast > ema_slow // trend
rsi in 35..65 // not extreme
adx > 25 // directional
price > vwap // above fair value
not_in_cooldown(2h) // no recent loss
fee_ratio_ok(30%) // fees won't kill profit
}
Exit conditions (OR)
Any single condition triggers a close:
exit when {
trailing_stop(callback: 1.5%)
or rsi > 75
or ema_fast crosses_below ema_slow
}
Operators
| Operator | Meaning | Example |
|---|---|---|
> < >= <= == != | Numeric comparison | rsi > 70 |
in | Range check (inclusive) | rsi in 30..70 |
crosses_above | Crossed above this cycle | ema9 crosses_above ema21 |
crosses_below | Crossed below this cycle | ema9 crosses_below ema21 |
or | OR (only valid in exit when) | or rsi > 80 |
Risk Management
risk {
max_position_pct: 5% // max 5% of capital per trade
position_size_score_3: 25% // score 3 → 25% of max
position_size_score_4: 65% // score 4 → 65% of max
position_size_score_5: 100% // score 5 → full max
stop_loss_atr: 1.5 // SL at 1.5x ATR below entry
take_profit_atr: 4 // TP at 4x ATR above entry
cooldown_after_loss: 2h // wait after a loss
max_daily_loss: 5% // stop trading if -5% today
}
Tiered sizing scales position size with the AI confidence score. A weak setup (score 3) risks less than a high-conviction one (score 5).
Schedule
schedule {
cycle_interval: 5m // minimum 1m
cautious_hours: [20,21,0,1] // UTC hours: tighter rules
cautious_confidence: 0.65 // vs 0.5 default
cautious_adx: 30 // vs 20 default
cautious_size_penalty: 50% // half size in cautious hours
dead_hours: [3,4] // no entries (existing positions managed)
}
AI Context
ai_context {
model: "deepseek" // or "user.my-llm"
prompt: "Trade only momentum setups."
min_confidence: 0.5 // LLM gate threshold
temperature: 0.3 // LLM creativity
}
System models: deepseek, openai, anthropic, meta. User models prefixed with user.
Built-in Functions
| Function | Block | Description |
|---|---|---|
top_volume(n, quote) | symbols | Top N pairs by 24h volume on the given quote |
trailing_stop(callback: %) | exit | Dynamic trailing stop, % from peak |
not_in_cooldown(duration) | entry | Returns true if no loss in the duration |
min_time_since_last_entry(d) | entry | Min time between entries on same symbol |
fee_ratio_ok(percent) | entry | True if expected fees ≤ % of expected profit |
dynamic_adx_floor() | entry | Returns 20 normally, 30 in cautious hours |
dynamic_confidence_floor() | entry | Returns 0.5 / 0.65 in cautious hours |
Built-in Variables
Available without declaring:
| Variable | Type | Notes |
|---|---|---|
price | number | Current symbol price |
capital | number | Bot's current cash |
leverage | number | 1 = spot, >1 = futures |
rsi, adx, atr, vwap, macd | number | Default-period indicators |
ema_fast, ema_slow | number | EMA(9) and EMA(21) |
volume | string | "normal", "elevated", "low" |
spread | number | Bid-ask spread % |
funding_rate | number | Futures funding rate |
confidence | number | 0–1, set by LLM gate |
hour | integer | Current UTC hour 0–23 |