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

[amibroker] Re: Rankings Help/Anthony



PureBytes Links

Trading Reference Links

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/