My BarsSinceN might help do what you want (which is not entirely 
clear to me).  I just figured it out for another purpose.

function BarsSinceN ( expression, n )
// Return number of bars since expression was true n times.
// If less than n, return value of BarIndex().
{
        return (BarIndex() - Nz(ValueWhen ( expression, BarIndex(), 
n )));
}

So if you want bars since the second to last time X happened, call 
BarsSinceN( X, 2 ).

If you want the bar index when that happened, use BarIndex() - 
BarsSinceN ( X, 2 ).  If you want the value of another array, Y, when 
that happened, use Ref ( Y, - BarsSinceN( X, 2 ) ), or more simply 
ValueWhen( X, Y, 2 ), except ValueWhen will return null values before 
the first 2 occurances.

--- In [email protected], "bernardedmond01" 
<[EMAIL PROTECTED]> wrote:
>
> Hi
> If I were buying on an upward cross of RSI(15) but I wanted to use 
as a 
> reference point the previous cross, how would I refer to this 
previous 
> cross? I don't want to use the "Barssince" function because there 
could 
> be either zero or multiple crosses in my chosen timeframe - I just 
> simply want to know when the last one occurred.
> Thanks
>


Reply via email to