Language quick-start · Complete language overview · Machine-readable specification
Strategy Builder Reference
Every condition, value ref, enum, and spec you can compose into a Quawd strategy. Each object links to its detail page with fields and the exact JSON schema.
Conditions
29
Value refs
43
Enums
32
Specs
0
▸Conditions
29 conditions
Conditions
Price signals
7 conditionsbreakout_retestBreakout followed by pullback retest
compareLEVEL comparison on continuous values: left op right, true whenever the relation holds. USE WHEN: gating on a sustained condition (e.g. close > SMA(200), RSI < 30 throughout the consolidation). DO NOT USE for one-shot edge events — use 'cross' to fire once on the crossing bar. DO NOT USE for membership in a discrete set — use 'in_set'. For named zones inspect builder_discover(action='get', ref='workflow:named_anchor_zone'); for anchor fields use value_ref:anchor.
crossEDGE event on continuous values: fires once on the bar where left crosses right (was below/above, now the other side). USE WHEN: price crosses a moving average, indicator crosses a level (e.g. RSI crosses 30), Stochastic K crosses D. DO NOT USE for discrete/categorical refs like supertrend.direction ({-1,+1}) — use 'transition' instead. DO NOT USE when you want whether the relation holds — use 'compare' for level/state semantics. For named zones inspect builder_discover(action='get', ref='workflow:named_anchor_zone').
in_setLEVEL membership on discrete/categorical values: true whenever value ∈ members (or its negation). USE WHEN: gating on SuperTrend direction == +1, regime label in {bull, neutral}. DO NOT USE on continuous values — use 'compare' instead. Cleaner than anyOf(compare(value == m) ...). The discrete-valued counterpart to 'compare'.
rangeLEVEL interval on continuous values: true whenever low <= subject <= high, with EACH bound's inclusivity set separately — low_inclusive and high_inclusive are BOTH REQUIRED, because the two two-bound sites this replaces disagree (band_level inside is exclusive on both edges, zone membership is inclusive on both), so any default would be a silent choice between them. USE WHEN: 'RSI between 30 and 70', 'price inside the Bollinger band', any half-open window like [30, 70) that a single flag cannot express. Bounds may be signal refs, not just constants, so they can be moving series. DO NOT USE for a one-sided threshold — use 'compare'. DO NOT USE for membership in a discrete set — use 'in_set'. A literal interval that is empty (low above high, or equal bounds with an exclusive end) is refused at construction rather than shipped as a strategy that never fires.
spreadSpread between two instruments (ratio, difference, log_ratio, zscore)
transitionEDGE event on discrete/categorical values: fires once on the bar where ref's value differs from the prior bar (optionally constrained to a (from, to) pair). USE WHEN: SuperTrend direction flips (-1 → +1), regime label changes, any small-set categorical ref changes value. DO NOT USE on continuous values like price or RSI — use 'cross' for those. The discrete-valued counterpart to 'cross'.
Price levels
4 conditionsPatterns
3 conditionscandle_patternCandlestick patterns (bullish_engulfing, bearish_engulfing, hammer, doji, morning_star, three_white_soldiers, etc. — see full enum via builder_discover(action='get', ref='condition:candle_pattern'))
flag_patternFlag chart pattern (momentum + consolidation + breakout)
pennant_patternPennant chart pattern
Temporal
3 conditionsat_leastAt least N of M conditions true on same bar — e.g. 3 of [CCI < -100, Donchian lower touch, volume spike, bullish divergence, hammer candle]
consecutiveCondition true for N consecutive bars (or N of M with strict=false) — e.g. close > SMA(100) for 5 consecutive bars. The window INCLUDES the current bar, so for 'X now but not in the preceding N bars' use window_bars=N+1 with min_true=2; window_bars=N with min_true=1 can never fire alongside X
latchEDGE with memory: true on the one close where `fire` holds after `arm` held on an earlier close, then disarmed. USE WHEN an event must follow a precondition — price re-enters a band after leaving it (arm=outside, fire=inside), first touch of a level after being clear of it, a rising edge of any condition (arm=not(c), fire=c). `arm` wins if both are true on one close; if either side has no value the result has none and the latch keeps its state. Never reset by positions. Children are inline conditions or condition_refs; it cannot hold a schedule or a stop/target. DO NOT USE for a plain level — use 'compare'.
Time & events
1 conditionRisk management
5 conditionsstopResting stop at a percent, ATR distance or absolute entry-fill price
targetResting profit target at a percent, ATR distance, price or stop-distance multiple
tiersAscending profit ladder with an explicit position share at each level
time_exitExit after a number of held bars, counting the fill bar as the first
trailNative standing stop at pct, atrs or a computed level; ratchets only in the position's favour
Combinators
5 conditionsall_ofLogical AND -- all child conditions must be true.
always_trueAlways true -- fires on every bar. Use as a no-op placeholder or unconditional trigger.
any_ofLogical OR -- at least one child condition must be true.
notLogical NOT -- inverts the inner condition.
sequenceOrdered sequence -- steps must fire in order, each optionally within N bars.
Custom Structures
1 condition▸Value refs
43 value refs
Value refs
Typed references that resolve to a number at evaluation time.
anchorA field of a named anchor — a single bar captured earlier and then held. The anchor is declared in the strategy's ``anchors`` (captured by timestamp, bar index, or the first false-to-true flip of a condition); referencing an ``anchor_id`` that is not declared blocks readiness. Until the anchor actually fires the value is typed absence. A comparison over that absent operand is UNKNOWN; the action boundary takes no action. ``mid`` and ``range`` are derived from the captured bar's high and low. Does not accept ``resolution``.
atBind a market subtree to one frame and/or instrument. For example, at(5m, close − ema20) binds both leaves to completed 5m bars. Use one at with untagged or agreeing leaves. Nested at and contradictory routes are refused: remove the inner at, or route its leaves explicitly. A non-native frame also refuses every bound leaf whose schema disallows resolution, with that leaf's reason and path; at grants no new capability. Combining an explicit symbol route with a non-native frame is refused. Use the symbol on the strategy frame, or run the strategy on that instrument and bind a higher frame without an explicit symbol route.
bars_sinceCompleted source-frame bars since condition last held within the window, in bars. Start and event windows update after decisions: bar t sees observations through t-1. Entry windows update before invested decisions, include t, and reset only on opening from flat and are absent while flat. Entry windows are refused in gates and event studies; entry conditions may read them, and formula sizing refuses them when their absence necessarily prevents the first entry. Guarded sizing can be admitted when the guard is available while flat and a branch can size before entry. Historical account state is never replayed. State survives paper checkpoints. Offset is refused. Bind leaf routes or use at; this value has no route fields. Inputs join at their finest frame; coarser children read their last completed bar and retain their history and readiness. Known gaps: a raw trailing ratchet does not reset after firing; an entry window includes the whole bar of a midbar scheduled fill and only the owning entry rule resets it. Scale-ins and partial exits do not reset it. Scheduled rules see their observed frame included. Observes warmup without trading; historical, routed and stateful consumption is refused. Direct arithmetic and conditional consumption is supported. Conditions admit compare, range, always_true and boolean composition over market values; cross, latch and other memoryful conditions are refused. Unknown matches do not count or capture. Absent until condition first holds. Start/event windows read zero on the bar after the matching bar; entry windows include the current bar and read zero on that bar.
binary_exprBinary expression over two ValueRef operands. ``left`` and ``right`` accept nested value references or finite numeric literals. Operators are +, -, *, /, min and max. Nest expressions to form spreads, ratios and scaled levels; apply unary_expr for transforms or rolling_stats for smoothing, then compare the result or use it for sizing. Symbol/resolution overrides belong on supporting leaf operands. Literal division by zero is refused. Readiness warns about known mismatches for +, -, min and max, naming the path and both dimensions. Numeric literals adopt the other dimension for +, -, min, max and comparisons. For * and /, either literal operand makes the dimension unknown; fully known operands derive dimensions (price / price is a ratio, currency / price is quantity, price * quantity is currency). Percent, ratio and oscillator scales stay distinct. Unknown dimensions never warn. Units stay advisory except a known sizing formula_unit contradiction. Consumer-specific admission still applies.
constantA fixed numeric literal, usable anywhere a value ref is accepted. The one ref that is NOT a ``ValueRefBaseModel``: it has no ``symbol`` or ``resolution`` qualifier. A bare int/float written into ``binary_expr``/ ``unary_expr`` operands or ``compare.right`` is coerced to this type automatically, so writing it out explicitly is rarely necessary.
countThe number of bars on which condition is known true within the window, in bars. Start and event windows update after decisions: bar t sees observations through t-1. Entry windows update before invested decisions, include t, and reset only on opening from flat and are absent while flat. Entry windows are refused in gates and event studies; entry conditions may read them, and formula sizing refuses them when their absence necessarily prevents the first entry. Guarded sizing can be admitted when the guard is available while flat and a branch can size before entry. Historical account state is never replayed. State survives paper checkpoints. Offset is refused. Bind leaf routes or use at; this value has no route fields. Inputs join at their finest frame; coarser children read their last completed bar and retain their history and readiness. Known gaps: a raw trailing ratchet does not reset after firing; an entry window includes the whole bar of a midbar scheduled fill and only the owning entry rule resets it. Scale-ins and partial exits do not reset it. Scheduled rules see their observed frame included. Observes warmup without trading; historical, routed and stateful consumption is refused. Direct arithmetic and conditional consumption is supported. Conditions admit compare, range, always_true and boolean composition over market values; cross, latch and other memoryful conditions are refused. Unknown matches do not count or capture.
entry_barReference to a field of the signal bar for the currently-open position. Auto-captured by the engine when a position opens. Returns NaN when no position is open. Clears on position close. Use for ORB-style "stop out below the signal-bar low" without AnchorDefinition's silent-latching bug. Fields: - open / high / low / close: signal-bar OHLC - range: high - low - body_high: max(open, close) - body_low: min(open, close)
equityThe strategy's running equity-curve value. ``field`` selects: ``current`` (equity right now), ``peak`` (the running high-water mark), or ``drawdown_pct`` (percent below that peak — 0 at a new high, positive while underwater). Use ``drawdown_pct`` directly for a circuit-breaker gate rather than deriving it from ``current``/``peak``. The sub-metric selector is named ``field``.
event_distanceDistance from the current bar to an event type's next or previous occurrence. ``direction="previous"`` counts back to the latest occurrence at or before the bar: 0 on the assignment bar only for unit="bars". Minutes uses elapsed wall-clock time from the occurrence timestamp to the bar timestamp. ``direction="next"`` counts forward to the earliest occurrence strictly after the bar, so it is never 0 in minutes. ``unit`` is wall-clock minutes or bars. When no such occurrence is known the value is infinity (present, not absent), so ``distance <= N`` is false and ``not (distance <= N)`` is true: that is how a "stay away from events" gate is written. A ``next`` distance needs the event's date to be known in advance. Among system events only those with a forward release calendar (macro.cpi, macro.nonfarm_payrolls, macro.unemployment) qualify; any other system event is refused with ``direction="next"``, because the platform cannot anticipate it. Custom events are unrestricted. Use ``direction="previous"`` to react after a system event. Example, bars since the latest occurrence: {"kind": "event_distance", "event_type_id": "my-signal", "direction": "previous", "unit": "bars"} Compared ``<=`` N it is true on the occurrence bar and the N bars after it, with <ref> the ref above: {"kind": "compare", "left": <ref>, "op": "<=", "right": N} That compare is also the proximity guard for an ``event_field`` read: put both under ``all_of`` so the payload comparison holds only near an occurrence instead of carrying forward until the next one.
event_fieldField from latest event payload. Custom observations can supply event payloads as well as built-in feeds. Inspect the capability catalogue for event-data operations available to this caller, then verify the type's schema and instrument coverage. A strategy that reads this event type's payload cannot also use that type's event_distance with direction='next', anywhere in the strategy. Authoring flow: 1. Call list_event_types(). 2. Pick event_type_id from a returned event type. 3. Pick event_field from payload_schema.fields. Example: {"kind": "event_field", "event_type_id": "macro.cpi", "event_field": "value"} To compare a release against a previous one, set occurrences_back on a second ref and subtract: {"kind": "binary_expr", "op": "-", "left": {"kind": "event_field", "event_type_id": "macro.cpi", "event_field": "value"}, "right": {"kind": "event_field", "event_type_id": "macro.cpi", "event_field": "value", "occurrences_back": 1}}
event_windowCalculation over distinct facts in a preceding knowledge-time window. Each fact contributes its latest eligible version. Corrections change its value without refreshing its original publication age. The interval includes its start and excludes the current read instant. Count, sum and distinct count return zero for an empty complete window; minimum and maximum are missing. Missing required fields or publication metadata remain missing.
highestThe highest known source value in the window, in the source unit. Start and event windows update after decisions: bar t sees observations through t-1. Entry windows update before invested decisions, include t, and reset only on opening from flat and are absent while flat. Entry windows are refused in gates and event studies; entry conditions may read them, and formula sizing refuses them when their absence necessarily prevents the first entry. Guarded sizing can be admitted when the guard is available while flat and a branch can size before entry. Historical account state is never replayed. State survives paper checkpoints. Offset is refused. Bind leaf routes or use at; this value has no route fields. Inputs join at their finest frame; coarser children read their last completed bar and retain their history and readiness. Known gaps: a raw trailing ratchet does not reset after firing; an entry window includes the whole bar of a midbar scheduled fill and only the owning entry rule resets it. Scale-ins and partial exits do not reset it. Scheduled rules see their observed frame included. Absent source values are skipped. Start and entry windows retain a paper seed-warmup limitation and admit broader per-symbol sources and consumers. Event windows observe warmup without trading and refuse historical and stateful consumption.
indicatorIndicator output — RSI, CCI, EMA/SMA, ATR, ADX, ROC (decimal: 0.05=5%), oscillators (rsi, srsi_k/d, stochastic_k/d, mfi) are 0-100 NOT 0-1 — oversold is `<= 5`, not `<= 0.05`. MACD/signal/histogram, stochastic_k/d, Bollinger bands, volume_sma, pivot levels. Use schema.variants.shape_refs to find the canonical shape ref for your authored indicator, then fetch it with builder_discover(action='get', ref=<returned ref>).
live_positionA metric of the CURRENTLY OPEN position, read live every bar (not a frozen snapshot from entry — contrast ``entry_bar``/``sequence_step``, which capture a value once and hold it). ``field`` selects: ``entry_price``, ``bars_in_position``, ``unrealized_pnl_pct`` / ``unrealized_pnl_usd``, or ``max_excursion_pct`` / ``min_excursion_pct``. All are NaN while flat. ``entry_price`` is the quantity-weighted entry of the units still held, and ``unrealized_pnl_pct`` is the side-correct return on it. The excursions are the best and worst GROSS price return the position has reached while held (side-correct, before fees; never below 0 and never above 0). Each bar's high and low are valued against the weighted entry of the units held after that bar's fills, so the whole bar uses the entry the position has then, whatever point of the bar a fill came at (an intra-bar approximation). The extremes survive an add and a sale of the first lot, and reset when the position closes or flips side. They are not an episode row's ``mfe_pct`` / ``mae_pct``, which are running profit over the peak cost (net of entry fees). ``bars_in_position`` counts the bars the position has been open in, INCLUDING the bar it filled in: it is 1 at the close of the fill bar, not 0. An exit on ``bars_in_position >= N`` therefore decides at the close of the Nth held bar and fills at the next bar's open, so the trade's ``exit_bar - entry_bar`` is exactly N. The sub-metric selector is named ``field``.
lowestThe lowest known source value in the window, in the source unit. Start and event windows update after decisions: bar t sees observations through t-1. Entry windows update before invested decisions, include t, and reset only on opening from flat and are absent while flat. Entry windows are refused in gates and event studies; entry conditions may read them, and formula sizing refuses them when their absence necessarily prevents the first entry. Guarded sizing can be admitted when the guard is available while flat and a branch can size before entry. Historical account state is never replayed. State survives paper checkpoints. Offset is refused. Bind leaf routes or use at; this value has no route fields. Inputs join at their finest frame; coarser children read their last completed bar and retain their history and readiness. Known gaps: a raw trailing ratchet does not reset after firing; an entry window includes the whole bar of a midbar scheduled fill and only the owning entry rule resets it. Scale-ins and partial exits do not reset it. Scheduled rules see their observed frame included. Absent source values are skipped. Start and entry windows retain a paper seed-warmup limitation and admit broader per-symbol sources and consumers. Event windows observe warmup without trading and refuse historical and stateful consumption.
named_valueRead a reusable value defined in this strategy by name or server id. Save a definition with add_rule(value=..., name=...), then use named_value wherever a full per-symbol value operand is accepted. References are stored by id, so renaming does not change their meaning. Definitions may reference other definitions; missing references and cycles are refused before writing. The source is inlined and the consumer's usual restrictions apply, including offset history scope, window aggregate/gate placement and structural stops. No arguments or project-wide lookup are supported. Research addresses source parameters once under /values/<id>/source, never separately at each use.
named_zoneA boundary of a named strategy-level zone: its `upper`, `lower`, or derived `mid`. ``mid`` is computed as ``(upper + lower) / 2`` at read time and is not a stored field. Zone boundaries may themselves be anchor refs, in which case the whole zone reads NaN until that anchor fires. Referencing an undeclared ``zone_id`` blocks readiness. Does not accept ``resolution``.
nowThe price at the rule's moment, on the strategy's own symbol. At the open it is the opening price; at any other time, the close of the last finished minute. Only a rule with a when reads it, in its own condition; a rule without one reads close.
offsetRead a market-derived value offset completed source-frame bars ago. Offset counts bars of its source; to step on strategy bars, wrap the source in sample. Mixed children use their finest frame, reading coarser children as of the last completed bar. Use sample(clock=primary) to count primary bars instead. Indicator/price leaf offsets count their own frame; swing offsets count confirmed swings. Missing historical values stay absent. Position, account, event, zone and cross-sectional histories are not supported. Nested offsets add, with at most 500 source-frame bars in total.
percentilePercentile RANK of the current bar's `field` (or of any `source` value) within the trailing `lookback_bars` window. Returns ``100 * (values strictly below the current one) / (lookback_bars - 1)`` over a window that **includes the current bar**: a new window high reads 100, a new window low reads 0. Ties are not counted, so a perfectly flat window reads 0. **This is the inverse of** ``rolling_stats(stat="percentile")``, which returns the *value* sitting at a given percentile level. Use this ref to ask "how extreme is price right now", and ``rolling_stats`` to ask "what price is the 90th percentile". NaN propagates: any missing value in the window returns NaN. ``source`` ranks any value ref rather than a price field, so "is the volume unusually high" or "is the band width unusually narrow" is one operand: ``lookback_bars`` (2 to 500) is the window the current value is ranked in. Every bar in the window is evaluated, so a long window over a nested expression costs more than a price field does. Example, the percentile of the Bollinger band width over 100 bars: {"kind": "percentile", "lookback_bars": 100, "source": {"kind": "binary_expr", "op": "-", "left": {"kind": "indicator", "indicator": "bollinger", "output": "upper"}, "right": {"kind": "indicator", "indicator": "bollinger", "output": "lower"}}}
priceA single OHLC field of the current bar, or of a bar `offset` bars back. ``offset=0`` (the default) is the bar being evaluated on the native frame. On a coarser frame (close@1d or at(1d, close) on intraday bars), it is the last COMPLETED source bar: yesterday's close until today's session closes. There, offset=1 reads two sessions back. Reading past the start of loaded history returns NaN rather than clamping to the first bar, and a NaN operand makes the enclosing compare false.
rankCross-sectional rank of ``source`` among the universe's symbols on the current bar, 0 to 1. The lowest symbol reads 0, the highest 1 (mid-rank for ties). With fewer than 2 symbols holding a value there is no rank: it is absent, so a comparison over it is unknown (not 0.5). ``source`` is evaluated once per symbol; it cannot carry a ``symbol`` and cannot contain another cross-sectional operand. Requires a universe or portfolio strategy with two or more symbols. Example, the top tercile of the universe by 20-bar rate of change: {"kind": "rank", "source": {"kind": "indicator", "indicator": "roc", "period": 20}} compared with ``> 0.66``.
rolling_maxHighest source value over exactly ``lookback_bars`` observations. ``include_current=false`` selects the prior N bars for breakouts. True selects the current completed bar and N-1 prior bars: use it for Ichimoku, stochastics, Williams %R and chandelier extrema. Source accepts any value ref, including indicators and expressions. Missing samples propagate NaN. For stochastic division guard a flat range with ``hi - lo <= 1e-9``.
rolling_minLowest source value over exactly ``lookback_bars`` observations. ``include_current=false`` selects the prior N bars for breakouts. True selects the current completed bar and N-1 prior bars: use it for Ichimoku, stochastics, Williams %R and chandelier extrema. Source accepts any value ref, including indicators and expressions. Missing samples propagate NaN. For stochastic division guard a flat range with ``hi - lo <= 1e-9``.
rolling_statsA statistic of the last 2..1000 source observations, INCLUDING the current bar. In addition to mean, std, zscore, sum, count, rank, percentile and ema: ``slope`` is the OLS slope in source units per bar, with oldest x=0 and newest x=N-1; ``linreg`` is that fitted line at the newest bar (no prediction offset). ``wma`` weights oldest1 through newestN. ``rma`` is Wilder smoothing with alpha1/N, SMA-seeded from N consecutive present samples, persistent thereafter; any absence clears its seed, as for EMA. ``highestbars`` / ``lowestbars`` return a nonnegative, unitless bar count 0..N-1 to the most recent tied maximum / minimum; current extremes return0. These age windows always include the current bar; rolling_max/min make that choice explicit through include_current. Finite windows propagate any absence rather than skipping missing samples. These operators accept custom arithmetic series and compose with offset; history retains market-only scope. Windows count source-frame bars; bind routes on leaves or at, and use sample for primary-clock observations. ``source`` accepts ANY value ref, including a nested ``binary_expr``, so this is the general smoothing and normalisation primitive: an SMA of an arbitrary expression is ``stat="mean"``, and a rolling z-score of a spread is ``stat="zscore"``. Combined with ``rolling_max``/``rolling_min`` it expresses whole indicator families that have no dedicated type — the %K of a stochastic over any series is a 3-bar ``"mean"`` of the normalised ratio. **Absence propagates**: one missing value in a finite window makes its result absent, and the enclosing compare unknown. Purpose-built indicators that compact their buffers to finite samples (``srsi_k``, ``stochastic_k``) survive undefined stretches that this ref does not, so they are not redundant with it. ``percentile_level`` is required when ``stat="percentile"`` and must be omitted otherwise. Composed RSI recipe (reference notation, authored as typed JSON): ``delta = close - offset(close, 1)``; ``avg_gain = rolling_stats(rma, max(delta, 0), N)``; ``avg_loss = rolling_stats(rma, max(-delta, 0), N)``; ``select(avg_loss <= 0 -> 100, else=100 - 100/(1 + avg_gain/avg_loss))``. This explicit guard chooses100 even when both averages are zero; native RSI leaves that initial all-flat case undefined. For stochastics use inclusive percentile100/0 as hi/lo and ``select(hi <= lo -> 0, else=100 * (src-lo)/(hi-lo))``. rolling_max/min select prior bars for breakouts with ``include_current=false``; set ``include_current=true`` for inclusive extrema, including Williams %R. A stochastic range guard should use ``hi - lo <= 1e-9`` rather than ``hi - lo <= 0`` to absorb floating-point noise on nearly flat series.
sampleObserve a routed market source on primary closes.
selectChoose a numeric value using a stateless predicate. True reads then, false reads else; unknown returns typed absence, never either branch. Only the chosen branch's absence propagates. Supports compare, range, in_set, not, all_of, any_of and always_true. Memoryful predicates are refused. Window aggregates, live_position and entry_bar values are supported in predicates and branches. Position-dependent values require a position-scoped consumer such as an exit, stop, target or trail. Bind symbol and resolution on children. Usable in arithmetic, offset, rolling statistics, window aggregate sources, sizing, existing stop/target refs and named values, under each consumer's restrictions. History and warmup take the maximum over predicate operands and both branches. Equal branch dimensions or a literal preserve units; known mismatch warns and yields unknown dimension.
sequence_stepReference to a field of the bar that matched a named sequence step. Address the bar that satisfied a specific step inside a specific SequenceCondition. Useful for "stop at the retest bar's low" in break-retest setups. Lifecycle mirrors EntryBarValueRef: the snapshot is captured at step fire, preserved for the lifetime of the open position, cleared on position close. NaN when no position is open or the step has not yet fired on the current match. Fields: - open / high / low / close: step-bar OHLC - range: high - low - body_high: max(open, close) - body_low: min(open, close)
sessionSession-level value reference. Day-scoped mode (default): resolves against the full trading day in the session timezone. field in {open, high, low, close, prior_close, bars_into_session, range, mid}. Intraday window mode: set ``window_start`` (HH:MM wall-clock in the session timezone) and ``window_duration_minutes`` to aggregate OHLC across a fixed intraday slot (e.g., Asian session 00:00+480, ORB 09:30+30). Before the window opens each day: NaN. During the window: evolving aggregate. After close: frozen aggregate for the rest of the day; resets at the next day's window_start. Fields prior_close and bars_into_session are day-scope only (not valid with a window).
shared_signalReference to a portfolio-level shared signal by name. Resolves only inside a multi-member portfolio that declares a matching ``shared_signals`` entry; bound to a member-local metric when the portfolio runs. Illegal in a standalone strategy.
siblingThe value of ``source`` on another symbol of the universe, on the current bar. ``symbol`` must be a member of the strategy's universe; one outside it never has a value, so such a strategy is not ready and the run refuses. ``source`` is evaluated on that symbol's own data, not this one's; it cannot carry a ``symbol`` and cannot contain another cross-sectional operand. Requires a universe or portfolio strategy with two or more symbols. Example, QQQ's close, to compare this symbol's close with: {"kind": "sibling", "symbol": "QQQ", "source": {"kind": "price", "field": "close"}}
swingPrice of a confirmed swing high/low — a bar whose extreme beats `strength` bars each side. Confirmation is **lagging by design**: a swing at bar N is not visible until bar ``N + strength``, because the bars to its right have to print first. That is what makes it lookahead-free, and it means the newest readable swing is always at least ``strength`` bars old. The comparison is strict, so a level matched exactly by a neighbouring bar never forms a swing. ``offset`` counts back through confirmed swings (0 = most recent); typed absence if that many have not been confirmed yet. A comparison over that absent operand is UNKNOWN; the action boundary takes no action.
timeReference to the current bar's time field. The sub-metric selector is named ``field``. Calendar/intraday fields: ``hour``, ``minute``, ``day_of_week`` (0=Mon), ``day_of_month``, ``month`` (1=Jan), ``minutes_since_midnight``. Session-aware fields (use the strategy's session metadata): ``minutes_to_close``, ``minutes_since_open``. Have no value for crypto (24h) and pre/post-market bars. A comparison over a missing value is unknown and takes no action, negated or not: ``not(minutes_to_close <= 5)`` does not fire outside the session.
todayFacts of the current session, fixed once it opens, and its change. ``open`` is the session's opening price; ``prior_close`` the previous session's close; ``gap_pct`` the open against the previous close, in percent; ``change_pct`` ``now`` against the previous close, in percent. Example, "gapped down more than 1%": compare {"kind": "today", "field": "gap_pct"} below -1.
totalThe sum of known source values in the window, in the source unit. Start and event windows update after decisions: bar t sees observations through t-1. Entry windows update before invested decisions, include t, and reset only on opening from flat and are absent while flat. Entry windows are refused in gates and event studies; entry conditions may read them, and formula sizing refuses them when their absence necessarily prevents the first entry. Guarded sizing can be admitted when the guard is available while flat and a branch can size before entry. Historical account state is never replayed. State survives paper checkpoints. Offset is refused. Bind leaf routes or use at; this value has no route fields. Inputs join at their finest frame; coarser children read their last completed bar and retain their history and readiness. Known gaps: a raw trailing ratchet does not reset after firing; an entry window includes the whole bar of a midbar scheduled fill and only the owning entry rule resets it. Scale-ins and partial exits do not reset it. Scheduled rules see their observed frame included. Observes warmup without trading; historical, routed and stateful consumption is refused. Direct arithmetic and conditional consumption is supported. Absent source values are skipped.
trade_historyA statistic computed from the strategy's own closed-trade history. ``field`` selects the metric: ``trade_count`` (closed trades so far), ``consecutive_wins`` / ``consecutive_losses`` (current streak length), ``last_pnl`` / ``last_pnl_pct`` (the most recently closed trade's PnL), ``rolling_win_rate`` / ``rolling_avg_pnl_pct`` (win rate / average PnL% over the last ``lookback_bars`` closed trades — ``lookback_bars`` is REQUIRED for these two and forbidden for every other field, since it counts TRADES, not bars), or ``bars_since_last_exit``. Before the first trade closes: ``trade_count``, ``consecutive_wins`` and ``consecutive_losses`` are all-time counters and read ``0``. The other five have no value yet -- a typed absence (``no_position``), not a number -- so a condition reading one is UNKNOWN and takes no action (neither true nor false), and a ``formula`` sizing over one blocks readiness because it could never size the first entry. The sub-metric selector is named ``field``.
triggering_zoneReference to the zone that fired the entry's ZoneCondition. Resolves to a level of the *triggering* zone — the zone selected by the entry's ZoneCondition on the signal bar. An immutable snapshot is captured into ``TradeContext`` so post-entry references (e.g. a standing stop-loss bound to the FVG's lower wick) keep resolving to the same zone for the trade's lifetime. The id is retained for persisted-state compatibility. Returns NaN when no triggering zone is bound (no entry condition with a required ZoneCondition fired) and no compatibility lookup is available.
unary_exprUnary expression over another ValueRef. ``source`` accepts a nested value reference or a finite numeric literal. Use abs/neg for magnitude/sign, log/log10 for logarithms, sqrt for square root, and pct_change for one-bar percent change (2 means 2%). Compose with binary_expr or rolling_stats, then use the result in a condition or sizing formula. Symbol/resolution overrides belong on supporting leaf operands. Dimension hints preserve abs/neg, halve exponents for sqrt and tag dimensioned log/log10 sources; subtracting equal log dimensions is a ratio. Unknown dimensions stay unknown. Invalid literal domains are refused; runtime missing values propagate. Consumer-specific admission and position context still apply.
value_atThe source value on the latest matching bar within the window, in the source unit. Start and event windows update after decisions: bar t sees observations through t-1. Entry windows update before invested decisions, include t, and reset only on opening from flat and are absent while flat. Entry windows are refused in gates and event studies; entry conditions may read them, and formula sizing refuses them when their absence necessarily prevents the first entry. Guarded sizing can be admitted when the guard is available while flat and a branch can size before entry. Historical account state is never replayed. State survives paper checkpoints. Offset is refused. Bind leaf routes or use at; this value has no route fields. Inputs join at their finest frame; coarser children read their last completed bar and retain their history and readiness. Known gaps: a raw trailing ratchet does not reset after firing; an entry window includes the whole bar of a midbar scheduled fill and only the owning entry rule resets it. Scale-ins and partial exits do not reset it. Scheduled rules see their observed frame included. Observes warmup without trading; historical, routed and stateful consumption is refused. Direct arithmetic and conditional consumption is supported. Conditions admit compare, range, always_true and boolean composition over market values; cross, latch and other memoryful conditions are refused. Unknown matches do not count or capture. An absent matching source clears the previous capture.
ValueRefThe union of all value references usable as a signal.
volumeTraded volume of the current bar, or of a bar `offset` bars back. Volume is in **base-asset units** (shares, or coins for crypto) unless the run is configured for quote units, in which case it is multiplied by that bar's close. Reading past the start of loaded history returns NaN.
xs_dispersionSpread of ``source`` across the WHOLE universe on the current bar. Unlike ``rank`` and ``xs_zscore`` it does not say where this symbol sits; every symbol reads the same number, so it does not degrade while this symbol's own value is still warming up. ``stat`` chooses the standard deviation or the range. ``source`` is evaluated once per symbol; it cannot carry a ``symbol`` and cannot contain another cross-sectional operand. Requires a universe or portfolio strategy with two or more symbols. Example, how widely 20-bar returns are spread across the universe: {"kind": "xs_dispersion", "stat": "stdev", "source": {"kind": "indicator", "indicator": "roc", "period": 20}}
xs_zscoreCross-sectional z-score of ``source`` among the universe's symbols on the current bar. How many sample standard deviations this symbol's value sits from the universe mean. With fewer than 2 values, or when every symbol sits on the mean, there is no z-score: it is absent (not 0). ``source`` is evaluated once per symbol; it cannot carry a ``symbol`` and cannot contain another cross-sectional operand. Requires a universe or portfolio strategy with two or more symbols. Example, how far this symbol's RSI is from the universe average: {"kind": "xs_zscore", "source": {"kind": "indicator", "indicator": "rsi", "period": 14}}
▸Enums
32 enums
Enums
Bounded option sets referenced by condition and value-ref fields.
Anchor Field6 values: close, high, low, mid, open, range
Calc Type4 values: difference, log_ratio, ratio, zscore
CompareOp6 values: !=, <, <=, ==, >, >=
Direction3 values: down, same, up
Direction3 values: both, high, low
Direction2 values: long, short
Direction2 values: next, previous
EntryBarField7 values: body_high, body_low, close, high, low, open, range
enum_bars_minutes2 values: bars, minutes
enum_close_open2 values: close, open
enum_fact_period2 values: fact, period
Field6 values: bars_in_position, entry_price, max_excursion_pct, min_excursion_pct, unrealized_pnl_pct, unrealized_pnl_usd
Field8 values: day_of_month, day_of_week, hour, minute, minutes_since_midnight, minutes_since_open, minutes_to_close, month
Field4 values: change_pct, gap_pct, open, prior_close
Field8 values: bars_since_last_exit, consecutive_losses, consecutive_wins, last_pnl, last_pnl_pct, rolling_avg_pnl_pct, rolling_win_rate, trade_count
Field3 values: current, drawdown_pct, peak
Fill2 values: none, previous
LevelDirection2 values: above, below
Op6 values: abs, log, log10, neg, pct_change, sqrt
Op6 values: *, +, -, /, max, min
Operation5 values: count, count_distinct, max, min, sum
PatternBias3 values: bearish, both, bullish
PatternName19 values: bearish_engulfing, bullish_engulfing, dark_cloud_cover, doji, dragonfly_doji, evening_star, gravestone_doji, hammer, harami, harami_cross, inside_bar, inverted_hammer, marubozu, morning_star, piercing_line, shooting_star, spinning_top, three_black_crows, three_white_soldiers
PriceField4 values: close, high, low, open
Session Field9 values: bars_into_session, close, high, in_session, low, mid, open, prior_close, range
Stat14 values: count, ema, highestbars, linreg, lowestbars, mean, percentile, rank, rma, slope, std, sum, wma, zscore
Stat2 values: range, stdev
Swing Type2 values: high, low
Timeframe7 values: 15m, 1d, 1h, 1m, 30m, 4h, 5m
Trigger Op4 values: above, below, crosses_above, crosses_below
ZoneLevel3 values: lower, mid, upper
ZoneSelection4 values: any, most_recent, nearest, oldest
▸Specs
0 specs
Specs
Reusable structured payloads shared across conditions.