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

Re: [amibroker] Relative Performance, was custom equity function for a foreign ticker [repost]



PureBytes Links

Trading Reference Links

Dave,

Something like this,

//Comparative Analysis

//Anthony Faragasso

//

/*Choose markets to compare current active chart with.*/

/*To reduce number of Tickers...just put "" next to mkt variable...example:
mkt1="";*/

mkt1="^GSPC";//change ticker here

mkt2="DELL";//change ticker here

mkt3="MSFT";//change ticker here

//Chose your timeframe for comparison

barsAgo=100;

barno=LastValue(Cum(1))-barsAgo;//Starts N last bars ago

//Pick one and comment the other out

timeframe=barno;//will start at the N bar ago.

//timeframe=Year();

//timeframe=Month();

/***************************************/

startpoint =
IIf(timeframe==Year(),ValueWhen(Year()!=Ref(Year(),-1),Cum(1)),IIf(timeframe
==Month(),ValueWhen(Month()!=Ref(Month(),-1),Cum(1)),IIf(timeframe==barno,ba
rno,Null))); // the start point of comparision will be Yearly or monthly or
N bar ago.

//Current Active Chart

price = Close;

Color=colorBlue;

Currentchart = 100 * ( price/ValueWhen( Cum(1) == startpoint, price ) - 1 );

//Comparison chart #1

Color1=colorRed;

ticker1 = ParamStr( "Ticker1", mkt1);

price1 = Foreign(mkt1, "C");

Chart1 = 100 * ( price1/ValueWhen( Cum(1) == startpoint, price1 ) - 1 );

//Comparison chart #2

Color2=colorYellow;

ticker2=ParamStr( "Ticker2", mkt2);

price2 = Foreign(mkt2, "C");

Chart2 = 100 * ( price2/ValueWhen( Cum(1) == startpoint, price2 ) - 1 );

//Comparison chart #3

Color3=colorWhite;

ticker3=ParamStr( "Ticker3", mkt3);

price3 = Foreign(mkt3, "C");

Chart3 = 100 * ( price3/ValueWhen( Cum(1) == startpoint, price3 ) - 1 );

/******************************************************/

Plot(Currentchart,"",color,styleLine);

Plot(Chart1,"",color1,styleLine);

Plot(Chart2,"",color2,styleLine);

Plot(Chart3,"",color3,styleLine);

//plots vertical line at yearly or monthly intervals

Plot(IIf(timeframe==Year(),Year()!=Ref(Year(),-1),IIf(timeframe==Month(),Mon
th()!=Ref(Month(),-1),IIf(timeframe==barno,Null,0))),"",colorBlack,styleOwnS
cale|styleHistogram);

//Some title information

barnotitle=WriteIf(timeframe==barno,EncodeColor(color)+Name()+WriteVal(Curre
ntchart)+"\n"+EncodeColor(color1)+ticker1+WriteVal(Chart1)+"\n"+EncodeColor(
Color2)+ticker2+WriteVal(Chart2)+"\n"+EncodeColor(Color3)+ticker3+WriteVal(C
hart3),"");

Monthly=WriteIf(timeframe==Month(),EncodeColor(color)+Name()+WriteVal(Curren
tchart)+"\n"+EncodeColor(color1)+ticker1+WriteVal(Chart1)+"\n"+EncodeColor(C
olor2)+ticker2+WriteVal(Chart2)+"\n"+EncodeColor(Color3)+ticker3+WriteVal(Ch
art3),"");

Yearly=WriteIf(timeframe==Year(),EncodeColor(color)+Name()+WriteVal(Currentc
hart)+"\n"+EncodeColor(color1)+ticker1+WriteVal(Chart1)+"\n"+EncodeColor(Col
or2)+ticker2+WriteVal(Chart2)+"\n"+EncodeColor(Color3)+ticker3+WriteVal(Char
t3),"");

/****************************************************/



Title=WriteIf(timeframe==Year(),"Yearly...",WriteIf(timeframe==Month(),"Mont
hly...",WriteIf(timeframe==barno,"Startpoint is ..(
"+WriteVal(ValueWhen(barno==Cum(1),DateTime()),formatDateTime)+" )","")))+".
.Comparative Analysis for
:...."+EncodeColor(Color)+Name()+".."+EncodeColor(Color1)+ticker1+".."+Encod
eColor(Color2)+ticker2+".."+EncodeColor(Color3)+ticker3+"\n"+WriteIf(timefra
me==Month(),Monthly,WriteIf(timeframe==Year(),Yearly,WriteIf(timeframe==barn
o,barnotitle,"")));


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/2003


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