[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


What do you want this to look like?

--- In amibroker@xxxxxxxxxxxxxxx, "enzo" <herrfrechdax@xxxx> wrote:
> 
> Hi, did 2 changes, it passes syntax-checking now, but the result is 
> always 2. 
> 
> regards
> enzo
> 
> 
> 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); // t=IIf(x-y=0,1,0);
> 	arun=arun+t;
> 	maxr=Max(arun,brun);
> 	brun=maxr;
> 	IIf(t==0,arun=1,arun=arun); //	if(t==0) arun=1;
> 	i=i+1;
> } while (i<n);
> Plot(brun,"",1,1);
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "liugq_99" <gliu@xxxx> wrote:
> > 
> > Sorry too late back on this. Thanks for giving suggestions. 
> However, 
> > the result is not quite I'm looking for. I have written VBscript 
> > codes to try the job. The codes are shown as below. Again, thanks.
> > 
> > liugq_99
> > 
> > 
> > EnableScript("vbscript");
> > 
> > ix=34;
> > 
> > //----------------------------------
> > 
> > r=log(c/Ref(c,-1))*100;
> > 
> > <%
> > rr=afl("r")
> > ix=afl("ix")
> > nsize=ubound(rr)
> > 
> > arun=0;
> > brun=0;
> > 
> > for i=0 to ix
> > xx=rr(i)
> > yy=rr(i-1)
> > arun=1
> > if (xx == yy) arun=arun+1
> > maxr=Max(arun,brun)
> > brun=maxr
> > i=i+1;
> > next i
> > 
> > afl(xy")=brun
> > %>
> > 
> > xy=brun;
> > 
> > Plot(xy,"",1,1);
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "Christoper" <turkey@xxxx> 
wrote:
> > > 
> > > 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/