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 Present | Behaviour |
|---|---|
Neither submitAt nor minutesBeforeClose | Submit exit immediately on fill |
submitAt | Submit exit at specified time |
minutesBeforeClose | Submit 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
| Field | Type | Default | Description |
|---|---|---|---|
submitAt | string | - | Time in HH:MM format to submit exit |
minutesBeforeClose | number | - | Minutes before close to submit (0-30) |
orderType | enum | "market" | market or moc |
timeInForce | enum | "day" | day or cls |
note
submitAt and minutesBeforeClose are mutually exclusive. Providing both will result in a validation error.
Behaviour
- Entry signal is submitted
- Entry order fills
- Exit signal is created automatically
- Exit order timing depends on configuration:
- No timing fields: Submit immediately
submitAt: Wait until specified time, then submitminutesBeforeClose: Wait until close minus N minutes, then submitorderType: "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"
}
}