Scan Rules (Advanced)
Scan Rules are boolean expressions used to decide whether a symbol matches. The advanced editor uses CEL-style syntax.
Syntax
Use comparisons and boolean logic. Expressions must evaluate to true or false.
// Comparison rsi_14 < 30 close > ma_50 // Boolean logic has_rsi_14 && has_ma_50 && rsi_14 < 30 && close > ma_50 (close > open) || (daily_move_pct > 5) // Perp-only example contract_type == "perp" && has_funding_rate && funding_rate > 0.001
Guard Pattern (Recommended)
For optional metrics, always check the matching has_* flag first. This prevents per-symbol evaluation failures on missing data.
// Good has_rsi_14 && has_ma_50 && rsi_14 < 30 && close > ma_50 // Risky (no guards) rsi_14 < 30 && close > ma_50
Price Alert Examples
Price alerts are regular scan rules built from symbol plus a price field such as close. In the Builder, the market selector usually handles spot vs perp for you, but you can make the contract explicit in Advanced mode when needed.
// BTCUSDT above a price on Binance spot symbol == "BTCUSDT" && contract_type == "spot" && close >= 100000.0 // BTCUSDT below a price on Binance perpetuals symbol == "BTCUSDT" && contract_type == "perp" && close <= 95000.0 // ETHUSDT below a price on Binance spot symbol == "ETHUSDT" && contract_type == "spot" && close <= 2500.0
If you already set the scan Market Type to spot or perp, the extra contract_type check is optional and mostly useful for documentation clarity.
Supported Variables
Source of truth: GET /api/crypto/scans/variables?contract_type=spot or GET /api/crypto/scans/variables?contract_type=perp.
Price
Indicators
Volume
Derived
Previous Candle
Deltas
Metadata
Safety Flags
Perp-only
Validation Rules
- Expression must return boolean
- Max length and AST complexity limits are enforced
- Banned functions:
matches(),split(),join() - Validation warnings are returned for likely missing guards