NinjaScript > Language Reference > Data >

Least Recent Occurence (LRO)

Print this Topic Previous pageReturn to chapter overviewNext page

Definition
Returns the number of bars ago that the test condition evaluated to true within the specified look back period expressed in bars. It checks from the furthest bar away and works toward the current bar. This method will NOT work on multi-instrument or multi-time frame strategies.
 

Method Return Value

An int value representing the number of bars ago. Returns a value of -1 if the specified test condition did not evaluate to true within the look back period.

 

Syntax
LRO(Condition condition, int instance, int lookBackPeriod)
 
The syntax for condition must be written in the following manner:

 

delegate { return your true/false condition;}
 

Parameters

condition

A true/false expression

instance

The occurrence to check for (1 is the least recent, 2 is the 2nd least recent, etc...)

lookBackPeriod

Number of bars to look back to check for the test condition. Test is evaluated on the current bar and the bars in the look back period.

 

 
Examples

// Prints the high price of the least recent up bar over the last 10 bars (current bar + look back period's 9 bars before that)
int barsAgo = LRO(delegate {return Close[0] > Open[0];}, 1, 9);
if (barsAgo > -1)
    Print("The bar high was " + High[barsAgo]);

 

 
See Also
Most Recent Occurence(MRO)