[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Previous/last occurrence



PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "bernardedmond01" 
<bernardedmond01@xxx> 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
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/