Back to builder reference

Value ref

trade_history

A 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 is refused at compile because it could never size the first entry.

VIB-1367 phase 4 / VIB-1319: the sub-metric selector is named field across every ValueRef-style type. The legacy name trade_metric was removed.

Backing types

TradeHistoryValueRef

Required fields

fieldreqenum: trade_count, consecutive_wins, consecutive_losses, last_pnl, last_pnl_pct, rolling_win_rate, rolling_avg_pnl_pct, bars_since_last_exit-

Optional fields

kindstring-
lookback_barsanyOf (2 variants)-
resolutionanyOf (2 variants)Optional higher-timeframe override for this value ref. Set it inside left/right refs such as {'kind': 'indicator', ..., 'resolution': '4h'} or {'kind': 'price', 'field': 'close', 'resolution': '4h'}. Do not put timeframe/source_timeframe on the parent condition. None = strategy timeframe.
symbolanyOf (2 variants)Optional reference symbol this value ref reads from (e.g. 'SPY'). None = the traded/primary symbol. Mutually exclusive with resolution.

Backing types

The IR ValueRef classes this builder field resolves to.

TradeHistoryValueRef
Quawd

A subscription SaaS platform for designing, backtesting, and paper-trading algorithmic trading strategies on equities and crypto — described in plain English to an AI agent, no code required.

© 2026 Quawd. All rights reserved.

Quawd is a software tool, not a broker-dealer or investment adviser, and does not provide investment advice. Trading involves substantial risk of loss. Backtested and hypothetical results have inherent limitations and are not indicative of future performance.