Spectra
Browse docs

backtester

Sizing modes

How position size is determined in backtests — fixed, percent of equity, ATR-based.


The backtester offers three sizing modes. Pick one in the Strategy panel; scripts can override per-call via buy(qty: ...).

Fixed

qty = constant  // e.g. buy(qty: 100)

Simplest. Useful when you're testing entry/exit logic without caring about position sizing.

Percent of equity

qty = floor(equity × pct / price)

Compounds gains and losses. Use to measure how a strategy behaves with realistic equity-curve dynamics. Default pct = 5%.

ATR-based (risk-equivalent)

qty = floor(risk_pct × equity / (atr(14) × atr_multiplier))

Sizes each position so the dollar risk to your stop is constant. The go-to mode for trend-following systems where ATR scales with volatility.

let size = atr_position(risk_pct: 1.0, atr: atr(14))
buy(qty: size)

Maximum constraints

All three respect:

  • Max position (Profile → Backtester → Max position).
  • Max concurrent positions (default 5).
  • Available equity — orders that would exceed buying power are rejected (or partially filled if partial_fill_on_margin = true).

Scaling in / out

buy(qty: size, scale: 0.5)   // adds half the size to existing position
sell(qty: size * 0.5)        // sells half

Scale-ins compound at the position's average entry. Scale-outs realize P&L proportionally.