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

[amibroker] Re: any ideas to reduce runtime for the price RS ranking code?



PureBytes Links

Trading Reference Links

Thanks, 

I couldn't get those to work completely. (Johan's mostly worked, but 
gave a lot of "{Empty}" where it shouldn't have.) 

I've also realised that the approach I suggested doesn't account for 
all time highs. So, I am just using a function to test for break of 
n-day high & low, called from within a do-while loop which 
progressively increases the value of n, (using "n=n*1.5;" and "while 
n<1000"). 

Not perfect, but it'll do for now. 

Thanks again. 

Chris


--- In amibroker@xxxxxxxxxxxxxxx, "johsun" <johanskatt@xxxx> wrote:
> Here's a function that seems to work. If you want to limit the 
> lookback period just use
> 
> for(i=LastValue(BarIndex())-lookback; i<BarCount; i++)
> 
> in the loop.
> 
> Regards,
> Johan
> 
> 
> 
> //-------------------------------------
> SetBarsRequired(100000,0);
> function nDayExtreme(f)
> //NOTE: f should be a string, "H" or "L".
> {
> n=Null; sgn=IIf(f=="H",-1,1);
> a=IIf(f=="H",H,IIf(f=="L",L,Null)); 
> if(LastValue(Cum(!IsTrue(a)))==0)
>  {
>  for(i=0; i<BarCount; i++)
>   {
>   for(j=i-1; j>=0; j--)
>    {
>    if(sgn*a[j]<sgn*a[i]){n[i]=i-j; /*break loop*/ j=-1;}
>    }
>   }
>  }
> return n;
> }
> 
> nH=nDayExtreme("H");
> nL=nDayExtreme("L");
> 
> Filter=nH>=20 OR nL>=20;
> AddColumn(nL,"nL",1.0);
> AddColumn(nH,"nH",1.0);
> 
> Plot(C,"",colorDefault,styleCandle);
> Title="It's been "+NumToStr(nL,1.0)+
> " bars since low was lower than current low,"+
> "\nand "+NumToStr(nH,1.0)+
> " bars since high was higher than current high";
> //----------------------------------------------
> 
> 
> 
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Kropotkin" <backup_dayad@xxxx> 
> wrote:
> > I should check - am I reinventing the wheel here? My basic aim is 
> to 
> > be able to find new highs without limiting the search to a certain 
> > period (e.g. if I search for prices crossing the prior 100 period 
> > high, this will miss the break of a 110 day high, and so on). Is 
> this 
> > built into a function? or has someone already written the code for 
> > this? 
> > 
> > I've looked but can't find anything. 
> > 
> > Thanks
> > Chris



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/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/