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

[amibroker] Need a help for a maximum run AFL code



PureBytes Links

Trading Reference Links


Hi,

A maximum run is defined as the maximum number of days (daily data) 
consecutive runing up or running down for a certain time of period. 
For example, a 100 day maximum run being 5 means the maximum number 
of days consecutively running up (or down) is 5.

I need a help to write a AFL code for this. Thanks.

liugq_99

My AFL code below has a "if" error:


r=log(C/Ref(C,-1));
n=100; //n--period

i=0;
arun=1;
brun=1;
do 
{
x=IIf(Ref(r,-i)>0,1,0);
y=IIf(Ref(r,-i-1)>0,1,0);
t=IIf(x-y=0,1,0);
arun=arun+t;
maxr=Max(arun,brun);
brun=maxr;
if(t==0) arun=1;
i=i+1;} while (i<n);

Plot(brun,"",1,1); 






------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

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

<*> 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/