RealTest User Guide
RealTest User Guide

 

 

Navigation: RealTest Script Language > Syntax Element Details >

ExitLimitTime

 

 

 

 

Category

Strategy Elements

Description

Specifies how a strategy exits positions when the ExitLimit formula is used

Choices

ThisClose - exit at today's close if today's closing price touches or exceeds the limit price (impractical)

Intraday - ExitLimit specifies the price of a live limit order to be placed tomorrow (default)

NextOpen - exit at tomorrow's open if today's close touched or exceeded the limit price

NextClose - exit at tomorrow's close if tomorrow's close touches or exceeds the limit price (calculated from today's bar)

OpenOnly - a limit order in the opening auction: exit at tomorrow's open if the open touches or exceeds the limit price; otherwise the order is cancelled, and the rest of the day does not fill it

Notes

Using ThisClose with ExitLimit is equivalent to adding "and C > n", where "n" is the ExitLimit price (for a long-side strategy), to the ExitRule of a strategy with ExitTime ThisClose. In either case, orders could not be generated in advance for this mode.

With Intraday, NextOpen, or NextClose ExitLimit orders, the trigger price is calculated using the prior bar, and the order can be placed in advance.

An Intraday ExitLimit is a standard LMT DAY order.

A NextOpen ExitLimit is a MKT order that is placed if the prior close touched the limit price.

A NextClose ExitLimit is a LOC (limit on close) order at the specified limit price.

An OpenOnly ExitLimit is a LMT OPG order where the exchange supports OPG (HasOpg in ExchangeMap.csv), otherwise a LMT order good until the exchange's LastOpenTime (9:31 for US stocks). In a backtest it fills at the open price, with LimitSlip when the open equals the limit price and OpenSlip when the open is better.

Since it is settled at the open, an OpenOnly limit combines with a NextClose ExitRule into a limit-on-open exit with a market-on-close fallback: both orders are generated in one OCA group, and with EntryTime: NextClose the position's slot and capital are free for that day's close entries, as with a plain NextClose exit. For example, to buy at the close and sell at the next open unless the open is more than 3% below the entry close, and then at that day's close:

Strategy: Overnight
    EntrySetup:    mySetup
    EntryTime:     NextClose
    ExitLimit:     C * 0.97
    ExitLimitTime: OpenOnly
    ExitRule:      1
    ExitTime:      NextClose

Note that the Exit Logic of a strategy works differently from its Entry Logic. Specifically, there is always only one Entry order, while there can be up to three Exit orders (ExitRule, ExitLimit and ExitStop), plus up to nine more limit and stop orders with Exit1 - Exit9. The exit orders each have their own time specifier and function as a "one-cancels-all" order bracket, where the order to logically trigger first becomes the position exit and the others do not.

To implement a trailing limit price, use PrevExitLimit in the ExitLimit price calculation.

For more information on how the backtest engine works in general, see Backtest Engine Details.

 

 

 

 

Copyright © 2020-2026 Systematic Solutions, LLC