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

Re: [amibroker] Comment From a newbie



PureBytes Links

Trading Reference Links

That seems to work well, but there is still the problem of system 
resources use - it slows down my computer so much, and when an 
auto-scan started, Amibroker hung and had to be foced close (first 
time in Amibroker). So, not suitable for me, but thanks for your work. 


I'll just use the LLV & HHV, as below - works well enough in practice. 

Cheers
Chris


//-------------------------------------
dut = 2;  // Don't Use Today's price (dut=1). If dut=2, doesn't 
trigger if the high being broken occurred in the previous two days.

nH = nL = 0; //ensure that value is 0 prior to first iteration of the 
function. Perhaps not necessary, but I like to be sure.


function  break (n)  //break of n period high or low.
{
HLine = Ref( HHV(H,n-dut ), -dut );
  bH = Cross(C, HLine); //AND HLine > HHV(Hi, dut ) ;
    nH = IIf(bH, Max(n,nH),nH);
LLine = Ref( LLV(L,n-dut ), -dut );
  bL = Cross(LLine, C); //AND LLine < LLV(Li, dut ) ;
    nL = IIf(bL, Max(n,nL),nL);
return;
}

break (20); //use whatever values of n you choose. 
break (50);
break (100);
break (200);  

Filter = nH>0 OR nL>0; 

AddColumn( IIf(nH>0, nH, IIf(nL>0,nL,Null) ),"H/L",1,colorDefault,
colorDefault );  //  This is the straightforward version. For the 
second term in the IIf function, I prefer IIf(nL>0,-666,nH), which 
will give nH, or the error flag which i chose as -666, to highlight if 
both nL and nH are >0, which would obviously mean an error in my 
formulas. 

//-------------------------------------




--- In amibroker@xxxxxxxxxxxxxxx, "johsun" <johanskatt@xxxx> wrote:
> Hi,
> 
> My code returns empty value whenever there is an all time high/low, 
> you cannot say that it's been n days since price was lower than 
> today if it's an all time low. However if you want the function to 
> return the barnumber in these cases just use the code below.
> 
> 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;}
> else n[i]=i; //     <--   added this line
> }
> }
> }
> 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:
> > 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



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