RealTest User Guide
RealTest User Guide

 

 

Navigation: RealTest Script Language > Syntax Element Details >

ExitTime

 

 

 

 

Category

Strategy Elements

Description

Specifies when a strategy exits positions at market when the ExitRule condition is true (non-zero)

Choices

ThisClose - exits occur at the close of the current day

NextOpen - exits occur at tomorrow's open (default)

Intraday - interpreted as NextOpen (a plain ExitRule has no intraday trigger; use ExitStopTime or ExitLimitTime for intraday stop or limit exits)

NextClose - exits occur at tomorrow's close

formula - a string formula that chooses NextOpen or NextClose for each position -- see Dynamic exit time below

Notes

Using ThisClose implies an ability to generate realtime trading signals using live data. RealTest will not be able to generate Tomorrow's Orders for ThisClose exits.

ExitTime controls the time at which a market order is generated. NextOpen implies that a standard MKT order is placed before the open, to be filled at the open. NextClose implies that a MOC order is placed before the open, to be filled at the close.

Dynamic exit time

Instead of one of the choices above, ExitTime can be a formula that returns the string "NextOpen" or "NextClose" ("Intraday" means NextOpen), for example to exit at Friday's close rather than Friday's open when the exit is decided on a Thursday:

ExitTime: iif(DayOfWeek = 4, "NextClose", "NextOpen")

The formula is evaluated for each position on the same bar as ExitRule (Thursday's bar in the example), so the choice is already known when Tomorrow's Orders are generated and each exit order gets the matching type (MKT on the open or MOC). It applies only to ExitRule exits; ExitLimitTime and ExitStopTime are unchanged.

The names must be quoted: an unquoted NextOpen inside a formula is the next bar's open price. Any other result stops the run with an error, and a result that cannot be calculated (NaN) means NextOpen. ThisClose cannot be chosen by a formula. A strategy specifies either a time name or a formula, not both, and a formula cannot be used with DynamicSizing. See EntryTime for how a NextClose exit's capital is reused by same-day entries.

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

 

 

 

Copyright © 2020-2026 Systematic Solutions, LLC