Navigation: Backtest Engine Details >

Specifying a Time Stop

 

 

 

 

The way to specify a Time Stop in RealTest is to reference the BarsHeld element in the ExitRule formula.

For example, a simple five-day time-stop rule would be:

If you entered a position on Monday and there are no holidays involved, you will exit the following Monday if you use the above formula.

An easy way to remember this is to think of BarsHeld as Nights Held (not counting weekend and holiday nights). If you enter on Monday and exit on Tuesday, then BarsHeld=1. If you exit on Wednesday, then BarsHeld=2, and so on.

When you review the Trade List of a test with Time Stop exits, you'll see that the Bars column always matches the number used in the BarsHeld equation for those trades, regardless of their exit time.

Note that this makes BarsHeld an exception to the logic described in the topic The Current Bar In Formula Evaluation. Wheres bar price references without an offset always refer to the most recently completed bar, BarsHeld includes the current bar in its count even when that bar has not been completed. Specifically, when your ExitTime is either NextOpen or NextClose, BarsHeld includes tomorrow's bar, even though no prices from that bar are available yet when ExitRule is being evaluated.

 

 

 

 

Copyright © 2020-2022 Systematic Solutions, LLC