Back to MCP catalog
builder_attach

Wire a condition card into a strategy slot (entry, exit, or gate) so the engine evaluates it.

Area

Strategy Builder

Group

Authoring

Access

Write

Risk

May change server state

Details

Full description

Wire a card into a strategy slot so the engine evaluates it during backtests. Call after building a card with builder_add_condition or builder_compose. Every strategy needs at least one entry attachment to trade.

Roles

  • entry — open a position when the card fires (requires direction="long" or "short")
  • exit — close the position when the card fires (size_frac controls partial exits). Set direction="long" or "short" to scope it; omit direction to apply it to BOTH sides.
  • gate — block all entries when the card is false (evaluated first)
builder_attach(strategy_id, card_id, role="entry", direction="long")
builder_attach(strategy_id, stop_id, role="exit", direction="long") # long only
builder_attach(strategy_id, time_exit_id, role="exit")                  # BOTH

Directional entry groups

  • Entry cards with the same direction are ANDed: all must fire on the same bar.
  • Long and short groups are alternatives. If both fire on one bar, the signal conflicts and no order is placed.
  • Bidirectional strategies enter only while flat.
  • No same-bar reversal: an opposite signal while invested is diagnostic only. Even if an exit fills on that bar, it does not enter the other side; the complete opposite entry group must fire again on a later bar while flat.
  • Sizing and exits whose direction is omitted are shared by both directions.

To express OR / NOT / sequence within one direction or for gates, combine conditions into one card with builder_compose. Gate cards are ANDed; exit cards remain independent and any firing closes.

Exit precedence — when multiple exits could fire on the same bar, the engine evaluates them in descending priority and exits on the first match. Default order: fixed_targets > trailing_stop > custom-condition exits; attachment order breaks ties within a tier.

Returns attachment_id and card_id. Use card_id (not attachment_id) for builder_detach.

Capabilities

Bounded options and operating modes surfaced above the full JSON schema.

Role options

role

entryexitgate

Required Inputs

card_idstringCard ID to attach
roleenum: entry, exit, gateCard role: entry, exit, or gate (block entries)
strategy_idstringStrategy ID

Optional Inputs

directionanyOf (2 variants)Entry role: required ('long' or 'short'). Exit role: optionally scope the exit to that position direction; None means BOTH long and short. Not used for gates.
size_fracanyOf (2 variants)Exit role: fraction to close, greater than 0 through 1. None = full close.
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.