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
| Field | Type | Default | Description |
|---|---|---|---|
exitTriggerType | enum | - | One of minutesAfterEntry, minutesBeforeClose, atClockTime, immediate. |
exitTriggerMinutes | integer | - | Minutes count (0-60). Required when exitTriggerType is minutesAfterEntry or minutesBeforeClose. |
exitTriggerTime | string | - | HH:MM (24-hour) submit time. Required when exitTriggerType is atClockTime. |
exitOrderType | enum | - | Exit order type: market, limit, stop, stopLimit, or moc. |
exitLimitPrice | number | - | Limit price for the exit. Required with limit or stopLimit; rejected otherwise. |
exitStopPrice | number | - | Trigger price for the exit. Required with stop or stopLimit; rejected otherwise. |
exitTimeInForce | enum | - | day or cls. cls is required for moc exits. |
Trigger types
| Type | Behaviour |
|---|---|
minutesAfterEntry | Schedule exit at entryFillTime + exitTriggerMinutes. |
minutesBeforeClose | Schedule exit at marketClose - exitTriggerMinutes. Rolls to the next market day if today is shut. |
atClockTime | Schedule exit at the next occurrence of exitTriggerTime (HH:MM, broker timezone). |
immediate | Submit the exit at fill time. Typically paired with exitOrderType: moc so the broker holds it. |
Validation rules
exitTriggerMinutesis required whenexitTriggerTypeisminutesAfterEntryorminutesBeforeClose.exitTriggerTimeis required whenexitTriggerTypeisatClockTime.mocexits must useexitTimeInForce: cls.mocpaired withminutesBeforeClosemust keep at least 15 minutes of head-room to clear broker CLS submission cutoffs.exitLimitPriceis required withlimitorstopLimitand rejected with any other order type.exitStopPriceis required withstoporstopLimitand rejected with any other order type.- All exit fields are optional. Omit
exitTriggerTypeand 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
- Entry signal is submitted.
- 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.
- UTM creates the exit, sized to the quantity that actually filled, and computes the submit time from the trigger fields.
- The exit signal is either submitted immediately or scheduled in the queue.
- When the schedule elapses, UTM submits the exit order at the configured
exitOrderTypeandexitTimeInForce.
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.
The exit only fires once the entry order is terminal.
- For an in-and-out trade, use
timeInForce: gtd(orday) 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: gtcleaves the entry working until it fully fills or you cancel it. If agtcentry only partially fills and keeps working, the timed exit will not fire, because the entry is never terminal. UTM returns theexit_rule_tif_may_not_terminateadvisory when you pair an exit rule with agtcentry. 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.