Navigation: Realtest Script Language > Syntax Element Details >

UntilTrue

 

 

 

Category

Multi-Bar Functions

Description

Count bars until a condition will be true

Syntax

UntilTrue(condition, count {0}) {WARNING: looks ahead}

Parameters

condition - formula referencing bar data

count - formula specifying a number of bars (optional)

Notes

The condition will be evaluated for the most recent bar first, then proceed forward in time until a non-zero value is found or count bars have been checked, whichever comes first. 

If count is omitted then there is no maximum (all bars after this one are potentially checked). 

If the condition never becomes true, the return value is -1. 

If the condition is currently true, the return value is 0. 

If the condition will be true tomorrow, the return value is 1, and so on.

Since this function looks into the future, it should generally not be used with price data in a backtest.

The most likely usage scenario would be date-related, e.g. UntilTrue(Month <> Month[1]) to count the number of remaining trading days this month.

 

 

 

Copyright © 2020-2021 Systematic Solutions, LLC