Skip to main content

Exit Rules Reference

Configure an automatic exit when an entry signal fills.

Overview

When you submit an entry signal you can attach exit instructions directly on the signal payload. After the entry order fills, UTM creates a corresponding exit signal based on these fields and either schedules it or submits it immediately. Exit fields are flat properties on the signal request body.

The shape is discriminated by exitTriggerType. The other fields are interpreted relative to that choice.

Field Reference

FieldTypeDefaultDescription
exitTriggerTypeenum-One of minutesAfterEntry, minutesBeforeClose, atClockTime, immediate.
exitTriggerMinutesinteger-Minutes count (0-60). Required when exitTriggerType is minutesAfterEntry or minutesBeforeClose.
exitTriggerTimestring-HH:MM (24-hour) submit time. Required when exitTriggerType is atClockTime.
exitOrderTypeenum-Exit order type: market, limit, stop, stopLimit, or moc.
exitLimitPricenumber-Limit price for the exit. Required with limit or stopLimit; rejected otherwise.
exitStopPricenumber-Trigger price for the exit. Required with stop or stopLimit; rejected otherwise.
exitTimeInForceenum-day or cls. cls is required for moc exits.

Trigger types

TypeBehaviour
minutesAfterEntrySchedule exit at entryFillTime + exitTriggerMinutes.
minutesBeforeCloseSchedule exit at marketClose - exitTriggerMinutes. Rolls to the next market day if today is shut.
atClockTimeSchedule exit at the next occurrence of exitTriggerTime (HH:MM, broker timezone).
immediateSubmit the exit at fill time. Typically paired with exitOrderType: moc so the broker holds it.

Validation rules

  • exitTriggerMinutes is required when exitTriggerType is minutesAfterEntry or minutesBeforeClose.
  • exitTriggerTime is required when exitTriggerType is atClockTime.
  • moc exits must use exitTimeInForce: cls.
  • moc paired with minutesBeforeClose must keep at least 15 minutes of head-room to clear broker CLS submission cutoffs.
  • exitLimitPrice is required with limit or stopLimit and rejected with any other order type.
  • exitStopPrice is required with stop or stopLimit and rejected with any other order type.
  • All exit fields are optional. Omit exitTriggerType and no automatic exit is created.

Examples

Timed Market Exit (30 minutes after entry)

{
"symbol": "AAPL",
"action": "openLong",
"accountId": "550e8400-e29b-41d4-a716-446655440000",
"quantity": 100,
"executeMode": "immediate",
"exitTriggerType": "minutesAfterEntry",
"exitTriggerMinutes": 30,
"exitOrderType": "market"
}

Limit Exit at a Specific Clock Time

{
"symbol": "AAPL",
"action": "openLong",
"accountId": "550e8400-e29b-41d4-a716-446655440000",
"quantity": 100,
"executeMode": "immediate",
"exitTriggerType": "atClockTime",
"exitTriggerTime": "15:50",
"exitOrderType": "limit",
"exitLimitPrice": 155.0,
"exitTimeInForce": "day"
}

Stop Exit 30 Minutes After Entry

Trigger a market exit if the symbol trades through exitStopPrice.

{
"symbol": "AAPL",
"action": "openLong",
"accountId": "550e8400-e29b-41d4-a716-446655440000",
"quantity": 100,
"executeMode": "immediate",
"exitTriggerType": "minutesAfterEntry",
"exitTriggerMinutes": 30,
"exitOrderType": "stop",
"exitStopPrice": 145.0
}

Stop-Limit Exit 30 Minutes After Entry

Same trigger as stop, but the broker only fills at or better than exitLimitPrice once triggered.

{
"symbol": "AAPL",
"action": "openLong",
"accountId": "550e8400-e29b-41d4-a716-446655440000",
"quantity": 100,
"executeMode": "immediate",
"exitTriggerType": "minutesAfterEntry",
"exitTriggerMinutes": 30,
"exitOrderType": "stopLimit",
"exitStopPrice": 145.0,
"exitLimitPrice": 144.0
}

Market On Close (MOC) Exit

Submit a market-on-close exit as soon as the entry fills. The broker holds the order until close.

{
"symbol": "AAPL",
"action": "openLong",
"accountId": "550e8400-e29b-41d4-a716-446655440000",
"quantity": 100,
"executeMode": "immediate",
"exitTriggerType": "immediate",
"exitOrderType": "moc",
"exitTimeInForce": "cls"
}

Exit 15 Minutes Before Close

{
"symbol": "AAPL",
"action": "openLong",
"accountId": "550e8400-e29b-41d4-a716-446655440000",
"quantity": 100,
"executeMode": "immediate",
"exitTriggerType": "minutesBeforeClose",
"exitTriggerMinutes": 15,
"exitOrderType": "moc",
"exitTimeInForce": "cls"
}

Behaviour

  1. Entry signal is submitted.
  2. The entry order reaches a terminal state at the broker: it fully fills, or it is cancelled or expires (for example when its time-in-force elapses) after a partial fill.
  3. UTM creates the exit, sized to the quantity that actually filled, and computes the submit time from the trigger fields.
  4. The exit signal is either submitted immediately or scheduled in the queue.
  5. When the schedule elapses, UTM submits the exit order at the configured exitOrderType and exitTimeInForce.

The exit quantity matches the actual filled quantity of the entry, not the originally-requested quantity.

UTM never cancels the entry order to create the exit. The exit waits until the entry can no longer change, then closes whatever filled. You decide when a working entry stops working through its time-in-force.

Match the entry's time-in-force to your exit

The exit only fires once the entry order is terminal.

  • For an in-and-out trade, use timeInForce: gtd (or day) on the entry. The entry goes terminal when it fills or when its time runs out, and the exit then fires for whatever filled.
  • timeInForce: gtc leaves the entry working until it fully fills or you cancel it. If a gtc entry only partially fills and keeps working, the timed exit will not fire, because the entry is never terminal. UTM returns the exit_rule_tif_may_not_terminate advisory when you pair an exit rule with a gtc entry. The signal is still accepted; the warning just flags the likely mismatch.

On clock-anchored exits (minutesBeforeClose, atClockTime), if the entry does not go terminal until after the clock time, the exit schedules for the next session rather than firing late. The strategy auto-close safety net is the backstop for closing the filled position the same day.