PureBytes Links
Trading Reference Links
|
hello herman,
thank you very much for your code -
works like a charm.
the moment i saw your code i
remembered your post about the "10 uses for #include". should have read that one
more closely ...
dirk
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Herman vandenBergen
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Wednesday, November 26, 2003 11:33
PM
Subject: RE: [amibroker] to TOMASZ: how
to loop through a list of tickers ?
<FONT face=Arial color=#0000ff
size=2>Hello,
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>The Exploration below will generate a complete correlation table
for the N100.
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>The leftmost column refers to the stock by number, since we do not have
string arrays in afl. You can add more colors to make this a heat map that
shows you instantly where pos/neg correlation exist. You can also use the
Osaka plugin to create csv exports for further analysis in Excel. The second
piece of code is an include file; copy it to your Include directory before
running the Exploration.
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>herman
//
Exploration N100 Correlation table<FONT
color=#000000> Buy<FONT
color=#000000>=Sell<FONT
color=#000000>=Short<FONT
color=#000000>=Cover<FONT
color=#000000>=0<FONT
size=2>; StkNum = <FONT
color=#0000ff>Status(<FONT
color=#ff00ff>"StockNum"<FONT
face=Arial>); <FONT
color=#ff0000>Filter = <FONT
color=#0000ff>Status(<FONT
color=#ff00ff>"LastBarInTest") <FONT
color=#ff0000>AND StkNum < <FONT
color=#ff00ff>50<FONT
color=#000000>; AddColumn<FONT
color=#000000>(StkNum," "<FONT
color=#000000>,1.0<FONT
size=2>); n = StkNum;
#include<FONT
face=Arial> <NtoN100Ticker.afl> Ticker1 =
Ticker; C1 = Foreign<FONT
color=#000000>(Ticker1,<FONT
color=#ff00ff>"C"<FONT
color=#000000>); <FONT
color=#ff0000>for(m=<FONT
color=#ff00ff>50;m<=<FONT
color=#ff00ff>99<FONT
color=#000000>;m++) { n=m;
<FONT
color=#ff0000>#include<FONT
color=#000000> <NtoN100Ticker.afl> Ticker2 =
Ticker; C2 = <FONT
color=#0000ff>Foreign(Ticker2,<FONT
color=#ff00ff>"C"<FONT
color=#000000>); Corr = <FONT
color=#0000ff>Correlation(C1, C2, <FONT
color=#ff00ff>8<FONT
color=#000000> ); Color = <FONT
color=#0000ff>IIf(Corr><FONT
color=#ff00ff>0,<FONT
color=#ff00ff>8,<FONT
color=#ff00ff>4); // Add
colors to make a heat map<FONT
face=Arial> <FONT
color=#0000ff>AddColumn(Corr,Ticker,<FONT
color=#ff00ff>1.3,<FONT
color=#ff00ff>1<FONT
color=#000000>,Color);
<FONT face="Courier New"
color=#000000><FONT face=Arial
size=2> }<SPAN
class=870081922-26112003>
// Include
file
Ticker
= WriteIf<FONT
color=#000000>(n==0 ,
"AAPL"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>1 , <FONT
color=#ff00ff>"ADBE"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==2 ,
"ADCT"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>3 , <FONT
color=#ff00ff>"ALTR"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==4 ,
"AMAT"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>5 , <FONT
color=#ff00ff>"AMGN"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==6 ,
"AMZN"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>7 , <FONT
color=#ff00ff>"APCC"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==8 ,
"APOL"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>9 , <FONT
color=#ff00ff>"BBBY"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==10 ,
"BEAS"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>11 , <FONT
color=#ff00ff>"BIIB"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==12 ,
"BMET"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>13 , <FONT
color=#ff00ff>"BRCD"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==14 ,
"BRCM"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>15 , <FONT
color=#ff00ff>"CDWC"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==16 ,
"CEPH"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>17 , <FONT
color=#ff00ff>"CHIR"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==18 ,
"CHKP"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>19 , <FONT
color=#ff00ff>"CHRW"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==20 ,
"CIEN"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>21 , <FONT
color=#ff00ff>"CMCSA"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==22 ,
"CMVT"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>23 , <FONT
color=#ff00ff>"COST"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==24 ,
"CPWR"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>25 , <FONT
color=#ff00ff>"CSCO"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==26 ,
"CTAS"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>27 , <FONT
color=#ff00ff>"CTXS"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==28 ,
"DELL"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>29 , <FONT
color=#ff00ff>"DISH"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==30 ,
"DLTR"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>31 , <FONT
color=#ff00ff>"EBAY"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==32 ,
"ERICY"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>33 , <FONT
color=#ff00ff>"ERTS"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==34 ,
"ESRX"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>35 , <FONT
color=#ff00ff>"EXPD"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==36 ,
"FAST"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>37 , <FONT
color=#ff00ff>"FHCC"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==38 ,
"FISV"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>39 , <FONT
color=#ff00ff>"FLEX"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==40 ,
"GENZ"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>41 , <FONT
color=#ff00ff>"GILD"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==42 ,
"GNTX"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>43 , <FONT
color=#ff00ff>"HGSI"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==44 ,
"HSIC"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>45 , <FONT
color=#ff00ff>"IACI"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==46 ,
"ICOS"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>47 , <FONT
color=#ff00ff>"INTC"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==48 ,
"INTU"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>49 , <FONT
color=#ff00ff>"IVGN"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==50 ,
"JDSU"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>51 , <FONT
color=#ff00ff>"JNPR"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==52 ,
"KLAC"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>53 , <FONT
color=#ff00ff>"LAMR"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==54 ,
"LLTC"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>55 , <FONT
color=#ff00ff>"LNCR"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==56 ,
"MCHP"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>57 , <FONT
color=#ff00ff>"MEDI"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==58 ,
"MERQ"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>59 , <FONT
color=#ff00ff>"MLNM"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==60 ,
"MNST"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>61 , <FONT
color=#ff00ff>"MOLX"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==62 ,
"MSFT"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>63 , <FONT
color=#ff00ff>"MXIM"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==64 ,
"NTAP"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>65 , <FONT
color=#ff00ff>"NVDA"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==66 ,
"NVLS"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>67 , <FONT
color=#ff00ff>"NXTL"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==68 ,
"ORCL"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>69 , <FONT
color=#ff00ff>"PAYX"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==70 ,
"PCAR"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>71 , <FONT
color=#ff00ff>"PDCO"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==72 ,
"PETM"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>73 , <FONT
color=#ff00ff>"PIXR"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==74 ,
"PSFT"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>75 , <FONT
color=#ff00ff>"PTEN"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==76 ,
"QCOM"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>77 , <FONT
color=#ff00ff>"QLGC"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==78 ,
"RFMD"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>79 , <FONT
color=#ff00ff>"ROST"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==80 ,
"RYAAY"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>81 , <FONT
color=#ff00ff>"SANM"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==82 ,
"SBUX"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>83 , <FONT
color=#ff00ff>"SEBL"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==84 ,
"SIAL"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>85 , <FONT
color=#ff00ff>"SNDK"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==86 ,
"SNPS"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>87 , <FONT
color=#ff00ff>"SPLS"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==88 ,
"SPOT"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>89 , <FONT
color=#ff00ff>"SSCC"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==90 ,
"SUNW"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>91 , <FONT
color=#ff00ff>"SYMC"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==92 ,
"TEVA"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>93 , <FONT
color=#ff00ff>"TLAB"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==94 ,
"VRSN"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>95 , <FONT
color=#ff00ff>"VRTS"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==96 ,
"WFMI"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>97 , <FONT
color=#ff00ff>"XLNX"<FONT
color=#000000>, WriteIf<FONT
color=#000000>(n==98 ,
"XRAY"<FONT
size=2>, <FONT
color=#0000ff>WriteIf(n==<FONT
color=#ff00ff>99 , <FONT
color=#ff00ff>"YHOO" , <FONT
color=#ff00ff>""
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
<SPAN
class=870081922-26112003> -----Original
Message-----From: dirk schreiber
[mailto:tianatrading@xxxxxxxxx]Sent: November 27, 2003 2:03
AMTo: amibroker@xxxxxxxxxxxxxxxSubject: [amibroker] to
TOMASZ: how to loop through a list of tickers ?
i'm a bit surprised to see that
noone is answering my call.
so may i ask you directly,
tomasz, if what i asked is possible and if you could indicate me the right
way to code this ??
thank you,
dirk
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
dirk
schreiber
To: <A
title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Monday, November 24, 2003 12:14
PM
Subject: Re: [amibroker] how to loop
through a list of tickers ?
noone ???
i'll try again: as an example,
is it possible to calculate all correlations of the stocks constituting
the nasdaq100 in one scan?
my code below will explore
the correlations of IBM with the other 99 constituents of my
nasdaq100 watchlist. is there a way in afl to tell amibroker to first
calculate these correlations for one stock, then go to the next and do the
same there and so forth, so that i could find out the 10 highest
correlations within the nasdaq100 for example ??
i have tried many ideas but i
am stuck (haven't mastered the new loop formulas very well yet)
...
any help would be greatly
appreciated, maybe this procedure would interest other amibroker users as
well.
thanks in advance,
dirk
pair=<FONT
color=#ff00ff>"IBM";
x=Foreign(pair,<FONT
color=#ff00ff>"C");
y=C;
xpc=ROC(x,<FONT
color=#ff00ff>1);
ypc=ROC(y,<FONT
color=#ff00ff>1);
Graph0=<FONT
color=#0000ff>Correlation(xpc,ypc,<FONT
color=#ff00ff>20);
Graph1=<FONT
color=#0000ff>Correlation(xpc,ypc,<FONT
color=#ff00ff>200);
Filter<FONT
face=Arial>=Graph0>0.7 AND
Graph1>0.5;<FONT
color=#0000ff>
AddColumn<FONT
face=Arial>(Graph0,<FONT
color=#ff00ff>"Cor20",<FONT
color=#ff00ff>1.2<FONT
color=#000000>);
AddColumn<FONT
face=Arial>(Graph1,<FONT
color=#ff00ff>"Cor200",<FONT
color=#ff00ff>1.2<FONT
color=#000000>);
AddColumn<FONT
face=Arial>(Graph0+Graph1,<FONT
color=#ff00ff>"total",<FONT
color=#ff00ff>1.2);
Buy<FONT
face=Arial>=0;<FONT
color=#000080>
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
<A title=tianatrading@xxxxxxxxx
href="">dirk schreiber
To: <A
title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Thursday, November 20, 2003
6:56 PM
Subject: [amibroker] how to loop
through a list of tickers ?
hello,
this is my first
post.
i have been working my way
into the ideas behind pair trading, reading the interesting posts by
yuki a few months ago and writing some code.
here is where i'm stuck: when
i calculate correlation, price ratio and other things like beta ratio it
is my understanding that when scanning my database i can only compare
one stock at a time with the rest of my universe. -- is it possible to
calculate all correlations between all stocks in one scan?? i know that
with big groups this would mean millions of calculations, but for a
group like the n100 this should be possible?
can this be done by some sort
of loop?
i searched the mailing list
archive and found only one hint by DT, talking about maybe using
something like Status("STOCKNUM") == 0 , but i
could not work that out ...
any help is
appreciated,
thanks in
advance,
<FONT face=Arial color=#000080
size=2>dirk<FONT face=Arial
size=2>Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href=""><FONT
face=Arial
size=2>http://groups.yahoo.com/group/amiquote/messages/)<FONT
face=Arial size=2>--------------------------------------------Check
group FAQ at: <A
href=""><FONT
face=Arial
size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT
face=Arial size=2> Your use of Yahoo! Groups is subject to
the Yahoo! Terms of
Service.
Do you Yahoo!?<A
href=""><FONT face=Arial
size=2>Protect your identity with Yahoo! Mail
AddressGuard<FONT face=Arial
size=2>Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page:
<FONT
face=Arial
size=2>http://groups.yahoo.com/group/amiquote/messages/)<FONT
face=Arial size=2>--------------------------------------------Check
group FAQ at: <A
href=""><FONT
face=Arial
size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT
face=Arial size=2> Your use of Yahoo! Groups is subject to the
Yahoo! Terms of
Service.
Do you Yahoo!?<A
href=""><FONT face=Arial
size=2>Protect your identity with Yahoo! Mail
AddressGuardSend
BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page:
<FONT
face=Arial
size=2>http://groups.yahoo.com/group/amiquote/messages/)<FONT
face=Arial size=2>--------------------------------------------Check
group FAQ at: <A
href=""><FONT
face=Arial
size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT
face=Arial size=2> Your use of Yahoo! Groups is subject to the
Yahoo! Terms of
Service.
Do you Yahoo!?<A
href=""><FONT face=Arial
size=2>Protect your identity with Yahoo! Mail
AddressGuardSend
BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
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.
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
|