Skip to main content
ATK Pine Script®

Order Type Matrix

Order-type matrix aligned to the unified execution core — MARKET, LIMIT, STOP_MARKET, STOP_LIMIT, BRACKET, and TRAILING_STOP_MARKET.

Order-Type Matrix Aligned to the Unified Execution Core#

PyneScript trade-frame contractRequired fieldsExecution-core meaningAlignment note
MARKETentry_order_type, entry_priceImmediate market-style intent.Maps directly to market-style core execution and is the safest cross-mode default.
LIMITentry_order_type, entry_limit_pricePrice-capped passive or resting intent.The canonical passive-price field is entry_limit_price.
STOP_MARKETentry_order_type, entry_trigger_priceTrigger first, then market execution.Stable across replay, backtest, and live adapters.
STOP_LIMITentry_order_type, entry_trigger_price, entry_limit_priceTrigger first, then submit a limit order.The current core keeps the distinction in replay/backtest and venue-capable live paths.
BRACKET entryDo not emit as a trade-frame entry type.Use a normal entry type plus sl and tp.This stays closer to the normalized execution contract.
TRAILING_STOP_MARKET entryDo not teach it as the primary entry type in the strategy layer.Use a normal entry plus trail_offset.Trailing is modeled through dedicated protective fields.

Portability: if you want portability across PyneScript strategy backtest, replay, and live signal execution, treat MARKET, LIMIT, STOP_MARKET, and STOP_LIMIT as the stable entry-type subset. Use dedicated trade-frame risk fields for bracket and trailing behavior.

Entry Fields: Direction, Price, and Sizing Base#

FieldPurposePractical rule
entry_sideTrade direction intent.Emit only on rows where a new entry actually exists. Empty string is safer than implicit carry-forward behavior.
entry_pricePrice basis for the order.Choose the series that matches your timing assumption: open, close, trigger, or limit basis.
quantityAbsolute size.Use for unit-based sizing. Keep size_pct neutral when quantity is the primary sizing model.
size_pctRelative size.Use when the strategy sizes by percent of capital or policy budget. Avoid mixing active quantity and active percent sizing in the same simple example.

Order-Type Examples You Can Adapt Directly#

MARKET entry#

frame["entry_side"] = np.where(frame["buy_signal"], "BUY", np.where(frame["sell_signal"], "SELL", ""))
frame["entry_order_type"] = "MARKET"
frame["entry_price"] = frame["open"]
frame["quantity"] = 1.0

LIMIT entry#

frame["entry_side"] = np.where(frame["buy_signal"], "BUY", "")
frame["entry_order_type"] = "LIMIT"
frame["entry_price"] = frame["close"]
frame["entry_limit_price"] = frame["close"] * 0.998
frame["quantity"] = 1.0

STOP_MARKET entry#

frame["entry_side"] = np.where(frame["breakout_signal"], "BUY", "")
frame["entry_order_type"] = "STOP_MARKET"
frame["entry_price"] = frame["close"]
frame["entry_trigger_price"] = frame["high"].rolling(5).max()
frame["quantity"] = 1.0

STOP_LIMIT entry#

frame["entry_side"] = np.where(frame["breakout_signal"], "BUY", "")
frame["entry_order_type"] = "STOP_LIMIT"
frame["entry_price"] = frame["close"]
frame["entry_trigger_price"] = frame["high"].rolling(5).max()
frame["entry_limit_price"] = frame["entry_trigger_price"] * 1.001
frame["quantity"] = 1.0