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

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



PureBytes Links

Trading Reference Links

In my last post, I put in code for break of high/low. Here's a better 
version, with a column that says whether it's a high or low. 

//-------------------------------------
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. 
AddTextColumn(WriteIf(nH>0, "High","")+WriteIf(nL>0, "Low",""),"H/L" )
;

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



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