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

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



PureBytes Links

Trading Reference Links


I tried looking at your code and coudln' figure out why AB was
thinking i or n were arrays and not just single numbers.

Having said that... I think you might be able to achiece what you want
without loops.  Take a look at this and let me know if this is waht
you are looking for.

Also, how are you using this?

----------start-----------
Lookback = 100;

Runup=HHV(BarsSince(Cross(C, Ref(C, -1))) * (C > Ref(C,-1))+1, Lookback );
Rundown=HHV(BarsSince(Cross(Ref(C, -1), C)) * (Ref(C,-1) > C)+1,
Lookback );

Plot(Runup,"Max Runup", colorGreen, styleLine);
Plot(rundown,"Max Rundown", colorRed, styleLine);
----------end-------------

--- In amibroker@xxxxxxxxxxxxxxx, "liugq_99" <gliu@xxxx> wrote:
> 
> 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/