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

[amibroker] Need code help



PureBytes Links

Trading Reference Links

I'm reposting because I think  I confused everyone with my 
terminology.

How can I get the following code to work.  The correlation function 
at the bottom of the code is giving a syntax error when I use a 
variable in the length.


SIG = Foreign("~SIGNAL","C");
FUND = C;
INDEX = Foreign("$RUT","C");

BARSTART = ValueWhen(SIG == 1 AND Ref(SIG != 1,-1),BarIndex(),3);
VLBRAW = BarIndex() - BARSTART;


/* FIND THE CLOSEST LOOKBACK PERIOD TO VBL1 LENGTH. WE WILL USE 
INCREMENTS OF 126 (1/2 OF 252 DAY YEAR) TO DO THIS.
VLBRAW = GET RAW VLB NUMBER AS VECTOR
VLB = USING IIF, FIND CLOSEST FIT.
*/

VLBRAWFACTOR = Max(round(VLBRAW / 126),1); //WHICH MULTIPLE OF 126 
IS BEST FIT?

VLB = IIf(VLBRAWFACTOR == 1, 126, IIf(VLBRAWFACTOR == 2, 252, IIf
(VLBRAWFACTOR == 3, 378, IIf(VLBRAWFACTOR == 4, 504, IIf
(VLBRAWFACTOR == 5, 630, 756))))); 

//CORR CHECKS
CORR = Correlation(ROC(FUND,1),ROC(INDEX,1),VLB);



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/