RecentOcc (Function)

image\trumpet2.gif Disclaimer

The RecentOcc function returns the number of bars ago a specified expression was True.

Syntax

RecentOcc(Test, Length, Instance, MLFlag)

Returns (Integer)

A numeric value containing the number of bars ago that the specified Test was True; -1 if Test was not found to be True within the last Length bars.

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.

MLFlag

Numeric

Sets which where to start searching, 1 = Most Recent, -1 = Least Recent

Remarks

The RecentOcc function is designed to identify when the ’Nth’ Instance of Test occurred. MLFlag Is used to determine if the function begins searching for the most recent occurrence or the least recent occurrence. Length specifies the number of bars to check for the condition.

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 that meets the criteria, it will return a -1.

  When using RecentOcc in an analysis technique, always check the result of the function before using the value in another calculation. If the condition occurred over Length number of bars, a -1 value will be returned.

Example

Value1 = RecentOcc(Close>0, 5, 1, 1);

See Also,

mro, LRO