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

[amibroker] Code help: Relative strength of two stocks with shorter history than base sym



PureBytes Links

Trading Reference Links


Hello,
 
With the code below, I can calculate the relative strength of two indicies (Growth vs Value in this case), but if I have a symbol selected with a history longer than the data available for the two symbols used in the rel str code, then I get null values.
 
I understand why, and tried to correct for this to find out how the first bar of the symbol with the shortest data.  Then, use that as the default bars back reference for rel str.  Can't get it to work though.
 
As always, thanks in advance for your help,
Gary
 
 

/* AFL calc relative strength of RUSSEL 2000 GROWTH vs. RUSSEL 2000 VALUE to determine funds are performing better.
This program calculates realtive strength of a FUND vs INDEX using FastTrack's methodology
*/
GROWTHSYM = ParamStr("GROWTH","!RUO"); //RUSSEL 2000 GROWTH
VALUESYM = ParamStr("VALUE","!RUJ"); //RUSSEL 2000 VALUE
GROWTH = Foreign(GROWTHSYM,"C");
VALUE = Foreign(VALUESYM,"C");
GR = BarsSince(Ref(GROWTH,-1) == Null);
VA = BarsSince(Ref(VALUE,-1) == Null);
BBMOD = Min(GR,VA);
RELSTR = ( GROWTH / Ref(GROWTH,-BBMOD) ) / ( VALUE / Ref(VALUE,-BBMOD) ) * 10;
RSMA = MA(RELSTR,50);
Plot(gr,"agr",colorDefault);
Plot(Va,"va",colorYellow);
Plot(RELSTR,"GROWTH vs VALUE",IIf(RELSTR > RSMA,34,13),styleLine|styleThick);
Plot(RSMA,"REL STR MA",colorBrown,styleLine|styleThick);
 
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software






Yahoo! Groups Sponsor


  ADVERTISEMENT









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 the Yahoo! Terms of Service.