Appearance

Personalize your experience

Mode
Accent Color
Direction
Orders and Fills

Orders and Fills

Backtesting

The event-driven engines of the Python and C++ SDKs share one set of order types and fill rules, so the same strategy fills identically in both languages and on the Quatick server.

Order types

TypeFillsPrice
marketat the next bar’s open (this bar’s close with trade_on_close)open (or close) plus slippage
limitbuy when price at or below the limit; sell at or abovethe limit, or the open if it gapped through (maker fee)
stopbuy when price at or above the stop; sell at or belowthe stop, or the open on a gap, plus slippage
stop_limita stop that then rests as a limit; may on one bar and fill on a later onethe price if within the limit, else the limit
trailinga stop that follows the by trail_pct or trail_amount, updated at each closelike a stop

Order options

OptionEffect
sl / tpbracket: when the order , a stop-loss and a take-profit are placed for the quantity , as an OCO pair
sl_pct / tp_pctthe same, as a percent from the fill price
reduce_onlymay only the position: clipped to it, cancelled when the position is flat
ocoorders sharing a group each other when one
tif = "day"expires after its first active bar
expire_barsexpires after this many active bars
taga label carried to the fill and the trade (entry_tag / exit_tag)

Timeline of a bar

  1. Orders active on the bar are tested against its price and in the order the path reaches them.
  2. The bar closes: trailing stops move, stop-limit triggers are remembered, expiring orders expire, equity is marked.
  3. The limit is checked; if hit, open orders are cancelled, the position is closed at the next open and trading stops.
  4. on_bar runs with bars up to this one and may send orders. They are active from the next bar (plus delay_bars). Bracket children are active from the bar after their entry .

The intrabar path

A bar only records open, high, low and close, so the engine assumes a : open → low → high → close on a bar that closed up and open → high → low → close on one that closed down. When a stop-loss and a take-profit both lie inside one bar, the one the reaches first and the other is cancelled. The rule is deterministic, so never depend on chance.

ℹ
Note:The assumption is conservative for trend-following longs on up bars (the low comes first, so stops are tested before targets) and optimistic for the opposite case. If many open and close inside one bar, test on a lower timeframe.

Accounting and risk

SettingEffect
costs / slippagethe engine’s cost models (percent, per unit, per order, India schedules, crypto maker / taker) and slippage (bps, ticks, square-root impact); limit pay maker fees and no slippage
allow_short = falsesells beyond the position are clipped; a short entry is
max_leverageorders that would raise gross exposure above this multiple of equity are (reason "margin")
max_participation are capped at this share of the bar’s volume; the rest stays working
max_drawdown_stop_pctflatten and halt at this from the equity peak
lot_size helpers down to lots

are matched first-in first-out from the , costs are split across partial closes, and open positions are marked at the last close. Each trade records its maximum adverse and favourable excursion (MAE / MFE) in percent of the .

See also

Related articles

  • DCA Capital & Leverage

    Automation / Predefined Strategies / DCA Bot

    Before placing a safety order the engine checks committed notional + order notional ≤ max capital × leverage and refuses the order if not. The base order is…

  • Grid Range

    Charts / Drawing Tools / Measurement

    Design a grid trading ladder directly on the chart. Drag out the price range the grid should trade and the tool derives every rung price, order size,…

  • Leverage & Base Price

    Automation / Predefined Strategies / Risk & Capital

    Leverage decides how much margin the ladder consumes — and how far the market can move before liquidation. Base price anchors the whole ladder.

  • Backtesting in Python and C++

    Backtesting / SDKs

    The quatick Python package and the header-only C++ library let you import indicators, backtest on your own machine and send the same file to Quatick.…

  • Brace

    Charts / Drawing Tools / Shapes

    A curly brace spanning a run of bars, placed with three clicks: the two ends of the span and a point setting how far it bulges. Says 'all of this, together'…

  • C++ SDK Reference

    Backtesting / SDKs / C++

    Header-only C++20 (packages/quatick-backtest-cpp): the position simulator, an event-driven engine with the same order rules as Python, analytics, a parallel…

  • Capital Allocation

    Automation / Predefined Strategies / Risk & Capital

    The ceiling the strategy may deploy — and the one number people get wrong, because the ladder's cost depends on the grid mode, not on the level count.

  • Default Order Mode

    Trading / Quick Trade / Display

    Set whether the Quick Trade bar uses Market or Limit orders by default.

  • Long Position

    Charts / Drawing Tools / Measurement

    A measurement tool that visualizes a long (buy) trade setup with entry price, stop-loss level, and one or more take-profit targets, including the calculated…

Browse all knowledge base articles →