Skip to main content

Exit Rules Reference

Automatic exit configuration for signals.

Overview

Exit rules automatically create an exit signal when an entry order fills. This enables strategies like:

  • Close at market close (day trading)
  • Close after N minutes (scalping)
  • Close at specific time

Exit rules use field presence to determine timing behaviour:

Fields PresentBehaviour
Neither submitAt nor minutesBeforeCloseSubmit exit immediately on fill
submitAtSubmit exit at specified time
minutesBeforeCloseSubmit exit N minutes before close

Immediate Exit (Default)

When no timing fields are specified, the exit order is submitted immediately when the entry fills.

{
"exitRule": {
"orderType": "market",
"timeInForce": "day"
}
}

Market on Close (MOC)

Place a Market on Close order that the broker holds until the closing auction.

{
"exitRule": {
"orderType": "moc",
"timeInForce": "cls"
}
}

The MOC order is submitted immediately on fill and held by the broker until market close. This is the recommended approach for day trading strategies that close at market close.

Scheduled Exit

Exit at a specific time or N minutes before market close.

Minutes Before Close

{
"exitRule": {
"minutesBeforeClose": 15,
"orderType": "market",
"timeInForce": "day"
}
}

Specific Time

{
"exitRule": {
"submitAt": "15:30",
"orderType": "market",
"timeInForce": "day"
}
}

Field Reference

FieldTypeDefaultDescription
submitAtstring-Time in HH:MM format to submit exit
minutesBeforeClosenumber-Minutes before close to submit (0-30)
orderTypeenum"market"market or moc
timeInForceenum"day"day or cls
note

submitAt and minutesBeforeClose are mutually exclusive. Providing both will result in a validation error.

Behaviour

  1. Entry signal is submitted
  2. Entry order fills
  3. Exit signal is created automatically
  4. Exit order timing depends on configuration:
    • No timing fields: Submit immediately
    • submitAt: Wait until specified time, then submit
    • minutesBeforeClose: Wait until close minus N minutes, then submit
    • orderType: "moc": Submit immediately, broker holds until close

Common Patterns

Day Trading (MOC Exit)

{
"exitRule": {
"orderType": "moc",
"timeInForce": "cls"
}
}

Safety Exit (15 Minutes Before Close)

{
"exitRule": {
"minutesBeforeClose": 15,
"orderType": "market",
"timeInForce": "day"
}
}

Time-Based Exit (3:30 PM)

{
"exitRule": {
"submitAt": "15:30",
"orderType": "market",
"timeInForce": "day"
}
}

Immediate Market Exit

{
"exitRule": {
"orderType": "market",
"timeInForce": "day"
}
}