LRO (Function)
The LRO (least recent occurrence) function returns the number of bars ago the specified expression was True. Or, if the specified expression did not occur within the last x number of bars, the function informs you of such.
Syntax
LRO(Test, Length, Instance)
Returns (Integer)
A numeric value containing the number of bars ago that the specified Test was True.
Parameters
Name |
Type |
Description |
Test |
TrueFalse |
Sets the true/false expression to check for (that is, Close > Open). |
Length |
Numeric |
Sets the number of bars to check. |
Instance |
Numeric |
Sets which occurrence, for example, 1 = most recent, 2 = 2nd most recent, and so on. |
Remarks
The LRO function is specifically designed to identify when a certain condition occurred. It checks from the bar furthest away and works toward the current bar.
The function always returns a number representing how many bars ago the true/false expression was fulfilled (0 = current bar, 1 = one bar ago, 2 = 2 bars ago …). If the function does not find a bar within the specified Length, which meets the criteria, it will return a -1.
When using the LRO function in an analysis technique, always check the result of the LRO function before using the value in another calculation or function. If Test is not true within Length number of bars, a -1 value will be returned.
Example
Value1 = LRO(Close>Open, 5, 1);
See Also