Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi oem
Here's a manual version of the indicator I created a while back. In it you can set up five favourite reference securities (with pathname) and replicate the MetaStock Relative Performance indicator. The calculation is quite simple and is shown in bold twxt in the last two sections. Hope this helps.
Roy
{Relative Performance (Manual)} {Roy Larsen 2011, 19/9/11}
{User Options} Sdm:=Input("Relative Performance, Starting Date - DDMM",0101,3112,0101); Sy:=Input("Starting Year - YYYY",1900,2020,2011); Ds:=Input("Start Bar Delay, 0=No 1=Yes",0,1,0); X:=Input("Reference, 1=Nikkei 2=DJIA 3=SPX 4=FTSI 5=HS" ,1,5,2);
Sd:=Int(0.1+Sdm/100); Sm:=Int(101*Frac(Sdm/100)); Start:=(DayOfMonth()>=Sd AND Month()=Sm AND Year()=Sy) OR Year()>Sy OR (Year()=Sy AND Month()>Sm); Start:=ValueWhen(1+Ds,1,Start);
{Referenced Indices} S1:=Security("C:\Equis\Stocks\World Indices\$NK ",CLOSE); {Nikkei 225} S2:=Security("C:\Equis\Stocks\World Indices\$DJ ",CLOSE); {DJIA} S3:=Security("C:\Equis\Stocks\World Indices\$SP ",CLOSE); {S&P 500} S4:=Security("C:\Equis\Stocks\World Indices\$FT ",CLOSE); {FTSI 100} S5:=Security("C:\Equis\Stocks\World Indices\$HS ",CLOSE); {Hang Seng}
{Select Index} Index:=If(X=1,S1,If(X=2,S2,If(X=3,S3,If(X=4,S4,S5))));
{Starting Date & Constant} Constant:=LastValue(ValueWhen(1,Cum(Start)=1,Index/CLOSE));
{Relative Performance} ValueWhen(1,Cum(Start)>0,CLOSE*Constant/Index);
|
1 user thanked mstt for this useful post.
|
|