PureBytes Links
Trading Reference Links
|
<FONT face=Arial color=#0000ff
size=2>It would be a very long column...about 100x100 combinations.
It is easier to copy-n-past the results to Excel and use an Excel formula to
find the max, like Max(...xy data range ...) and/or
use <FONT
face=Arial color=#0000ff size=2>Excel Conditional formating to color cells
according to the limits.
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>DT recently posted a nice solution to extract the highest values from the
table... I think that might do exactly what you want.
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>herman
<FONT face=Tahoma
size=2>-----Original Message-----From: qqqqq_99999_qqqqq
[mailto:qqqqq_99999_qqqqq@xxxxxxxxx]Sent: December 30, 2003 8:14
AMTo: amibroker@xxxxxxxxxxxxxxxSubject: [amibroker] Re:
to HERMAN: N100 Correlation tableHi,Is there
any way to create a correlation table in a columnal form (security1,
security2 and correaltion columns ) for easy sorting?ysk--- In
amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko"
<amibroker@xxxx>wrote:> Hello,> > The code is
written in ineffective way because it calls Foreign forCURRENT security
while it is not necessary at all.> Also it performs two loops when only
one is needed.> > More efficient version is here:>
> Filter = Status("LastBarInTest"); > list = GetCategorySymbols(
categoryWatchlist, 0 ); > >
AddTextColumn(Name(),"Correlation",1.0); > Ticker1= Name(); >
> for( Col=0; (Ticker2=StrExtract( List, Col))!= ""; Col++) > {
> Var2 = Foreign(Ticker2,"C");
> Corr = Correlation( C, Var2, 8 );
> Color = IIf(Corr>0, colorBrightGreen,
IIf(Corr<0,colorRed,colorWhite)); > Color =
IIf(Ticker1==Ticker2, 1, Color); > AddColumn( Corr,
Ticker2, 1.3, 1, Color); > } > > Hope this helps.>
> Best regards,> Tomasz Janeczko>
amibroker.com> ----- Original Message -----
> From: Herman vandenBergen > To:
amibroker@xxxxxxxxxxxxxxx > Sent: Friday, November 28, 2003
10:24 AM> Subject: RE: [amibroker] Re: to HERMAN: N100
Correlation table> > > Very nice DT, thanks!
I'll be using that frequently. Below is whatthe Correlation matrix, with
help from the list, developed into. > //
Exploration to create Correlation matrix>
Buy=Sell=Short=Cover=0; > Filter =
Status("LastBarInTest"); > list =
GetCategorySymbols( categoryWatchlist, 2 ); >
for( NumTickers=0; (StrExtract( list, NumTickers )) != "";NumTickers++ );
> AddTextColumn(Name(),"Ticker",1.0);
> for( Col=0; Col<NumTickers; Col++)
> {
> Ticker1 = Name();
> Ticker2 = StrExtract( list,
Col); > Var1 =
Foreign(Ticker1,"C"); > Var2
= Foreign(Ticker2,"C"); >
Test = Correlation( Var1, Var2, 8 );
> Color = IIf(Test>0,
colorBrightGreen, IIf(Test<0, colorRed,colorWhite));
> Color =
IIf(Ticker1==Ticker2, 1, Color);
> AddColumn( Test, Ticker2,
1.3, 1, Color); > } >
> > > -----Original
Message-----> From: DIMITRIS TSOKAKIS
[mailto:TSOKAKIS@xxxx]> Sent: November 28, 2003
1:46 PM> To:
amibroker@xxxxxxxxxxxxxxx> Subject: [amibroker]
Re: to HERMAN: N100 Correlation table> >
> Herman,> There
is no need to write the 100 tickers. If they belong toWL10,
> then> list =
GetCategorySymbols( categoryWatchlist, 10 );>
tickerlist="";> for( i = 0; ( sym = StrExtract(
list, i ) ) != ""; i++ )>
{>
tickerlist=tickerlist+sym+",";>
}>
Title=tickerlist;> The advantage is that you
don't have to correct the code afterany >
N100 change, it is done automatically as soon as you
correctWL10.> Note also that
StrExtract() needs a "comma-separated list ofitems",
> that's why the above +",".
> The result will have a "," at the end, but
this is not aproblem.> Dimitris
Tsokakis> --- In amibroker@xxxxxxxxxxxxxxx,
"Dave Merrill"<dmerrill@xxxx> >
wrote:> > I've lost track of the original
context, but could you do thiseven >
more> > easily by iterating through the
tickers in a known watchlist?> >
> > Dave>
> > > this is actually the
"data" type statement I have beenlooking >
for....> > wanted to store individual
thresholds in some easy way - thisis >
easier than> > a file system
:-)> > >
> herman>
> -----Original
Message-----> >
From: Tomasz Janeczko [mailto:amibroker@xxxx]>
> Sent: November 28, 2003 7:37
AM> > To:
amibroker@xxxxxxxxxxxxxxx>
> Subject: Re: [amibroker] Re: to HERMAN: N100
Correlationtable> >
> > >
> Hello,> >
> > It would be
shorter to write this that way:> >
> > TickerList
=>
>"AAPL,ADBE,ADCT,ALTR,AMAT,AMG,AMZ,APCC,APOL,BBBY,BEAS,BIIB,BMET,BRCD>
,BRCM,CD> >
WC,CEPH,"+> >
>
>"CHIR,CHKP,CHRW,CIE,CMCSA,CMVT,COST,CPWR,CSCO,CTAS,CTXS,DELL,DISH,DL>
TR,EBAY,> >
ERICY,ERTS,"+> >
>
>"ESRX,EXPD,FAST,FHCC,FISV,FLEX,GEZ,GILD,GTX,HGSI,HSIC,IACI,ICOS,ITC,>
ITU,IVG,> >
JDSU,JPR,KLAC,"+> >
>
>"LAMR,LLTC,LCR,MCHP,MEDI,MERQ,MLM,MST,MOLX,MSFT,MXIM,TAP,VDA,VLS,XTL>
,ORCL,PA> >
YX,PCAR,PDCO,"+> >
>
>"PETM,PIXR,PSFT,PTE,QCOM,QLGC,RFMD,ROST,RYAAY,SAM,SBUX,SEBL,SIAL,SDK>
,SPS,SPL> >
S,SPOT,SSCC,"+> >
"SUW,SYMC,TEVA,TLAB,VRS,VRTS,WFMI,XLX,XRAY,YHOO";>
> > > Ticker =
StrExtract( TickerList, n );> >
> > Hope this
helps.> > >
> Best regards,>
> Tomasz Janeczko>
> amibroker.com>
> ----- Original Message
-----> >
From: dirk schreiber>
> To:
amibroker@xxxxxxxxxxxxxxx>
> Sent: Thursday, November 27, 2003
9:58 PM>
> Subject: Re: [amibroker] Re: to
HERMAN: N100 Correlationtable> >
> > >
> hi
nand,> > >
> the #include file was posted by
herman before, it goeslike >
this:> > >
> // Include
file> >
Ticker =>
> WriteIf(n==0 ,
"AAPL",>
> WriteIf(n==1 ,
"ADBE",>
> WriteIf(n==2 ,
"ADCT",>
> WriteIf(n==3 ,
"ALTR",>
> WriteIf(n==4 ,
"AMAT",>
> WriteIf(n==5 ,
"AMGN",>
> WriteIf(n==6 ,
"AMZN",>
> WriteIf(n==7 ,
"APCC",>
> WriteIf(n==8 ,
"APOL",>
> WriteIf(n==9 ,
"BBBY",>
> WriteIf(n==10 ,
"BEAS",>
> WriteIf(n==11 ,
"BIIB",>
> WriteIf(n==12 ,
"BMET",>
> WriteIf(n==13 ,
"BRCD",>
> WriteIf(n==14 ,
"BRCM",>
> WriteIf(n==15 ,
"CDWC",>
> WriteIf(n==16 ,
"CEPH",>
> WriteIf(n==17 ,
"CHIR",>
> WriteIf(n==18 ,
"CHKP",>
> WriteIf(n==19 ,
"CHRW",>
> WriteIf(n==20 ,
"CIEN",>
> WriteIf(n==21 ,
"CMCSA",>
> WriteIf(n==22 ,
"CMVT",>
> WriteIf(n==23 ,
"COST",>
> WriteIf(n==24 ,
"CPWR",>
> WriteIf(n==25 ,
"CSCO",>
> WriteIf(n==26 ,
"CTAS",>
> WriteIf(n==27 ,
"CTXS",>
> WriteIf(n==28 ,
"DELL",>
> WriteIf(n==29 ,
"DISH",>
> WriteIf(n==30 ,
"DLTR",>
> WriteIf(n==31 ,
"EBAY",>
> WriteIf(n==32 ,
"ERICY",>
> WriteIf(n==33 ,
"ERTS",>
> WriteIf(n==34 ,
"ESRX",>
> WriteIf(n==35 ,
"EXPD",>
> WriteIf(n==36 ,
"FAST",>
> WriteIf(n==37 ,
"FHCC",>
> WriteIf(n==38 ,
"FISV",>
> WriteIf(n==39 ,
"FLEX",>
> WriteIf(n==40 ,
"GENZ",>
> WriteIf(n==41 ,
"GILD",>
> WriteIf(n==42 ,
"GNTX",>
> WriteIf(n==43 ,
"HGSI",>
> WriteIf(n==44 ,
"HSIC",>
> WriteIf(n==45 ,
"IACI",>
> WriteIf(n==46 ,
"ICOS",>
> WriteIf(n==47 ,
"INTC",>
> WriteIf(n==48 ,
"INTU",>
> WriteIf(n==49 ,
"IVGN",>
> WriteIf(n==50 ,
"JDSU",>
> WriteIf(n==51 ,
"JNPR",>
> WriteIf(n==52 ,
"KLAC",>
> WriteIf(n==53 ,
"LAMR",>
> WriteIf(n==54 ,
"LLTC",>
> WriteIf(n==55 ,
"LNCR",>
> WriteIf(n==56 ,
"MCHP",>
> WriteIf(n==57 ,
"MEDI",>
> WriteIf(n==58 ,
"MERQ",>
> WriteIf(n==59 ,
"MLNM",>
> WriteIf(n==60 ,
"MNST",>
> WriteIf(n==61 ,
"MOLX",>
> WriteIf(n==62 ,
"MSFT",>
> WriteIf(n==63 ,
"MXIM",>
> WriteIf(n==64 ,
"NTAP",>
> WriteIf(n==65 ,
"NVDA",>
> WriteIf(n==66 ,
"NVLS",>
> WriteIf(n==67 ,
"NXTL",>
> WriteIf(n==68 ,
"ORCL",>
> WriteIf(n==69 ,
"PAYX",>
> WriteIf(n==70 ,
"PCAR",>
> WriteIf(n==71 ,
"PDCO",>
> WriteIf(n==72 ,
"PETM",>
> WriteIf(n==73 ,
"PIXR",>
> WriteIf(n==74 ,
"PSFT",>
> WriteIf(n==75 ,
"PTEN",>
> WriteIf(n==76 ,
"QCOM",>
> WriteIf(n==77 ,
"QLGC",>
> WriteIf(n==78 ,
"RFMD",>
> WriteIf(n==79 ,
"ROST",>
> WriteIf(n==80 ,
"RYAAY",>
> WriteIf(n==81 ,
"SANM",>
> WriteIf(n==82 ,
"SBUX",>
> WriteIf(n==83 ,
"SEBL",>
> WriteIf(n==84 ,
"SIAL",>
> WriteIf(n==85 ,
"SNDK",>
> WriteIf(n==86 ,
"SNPS",>
> WriteIf(n==87 ,
"SPLS",>
> WriteIf(n==88 ,
"SPOT",>
> WriteIf(n==89 ,
"SSCC",>
> WriteIf(n==90 ,
"SUNW",>
> WriteIf(n==91 ,
"SYMC",>
> WriteIf(n==92 ,
"TEVA",>
> WriteIf(n==93 ,
"TLAB",>
> WriteIf(n==94 ,
"VRSN",>
> WriteIf(n==95 ,
"VRTS",>
> WriteIf(n==96 ,
"WFMI",>
> WriteIf(n==97 ,
"XLNX",>
> WriteIf(n==98 ,
"XRAY",>
> WriteIf(n==99 , "YHOO" ,
""> >
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))>
))))))))> >
))))))))))))))))))))))))))))));> >
> >
dirk>
> ----- Original Message
----->
> From:
nkis22>
> To:
amibroker@xxxxxxxxxxxxxxx>
> Sent: Thursday, November
27, 2003 5:16 PM>
> Subject: [amibroker] Re:
to HERMAN: N100 Correlationtable> >
> > >
> Will appreciate very much
to see the #include AFLplease>
> thanks in
advance>
>
nand> > >
> > > >
> > > >
> > > >
> >
> --- In
amibroker@xxxxxxxxxxxxxxx, dirk schreiber >
<tianatrading@xxxx>>
>
wrote:>
> > hello
herman,>
>
>>
> > after playing around
with your code a little bit, i > realized
that>
> it is not showing a
COMPLETE "heat list" of the n100. > by
"splitting>
> up" the 100 stocks into
two groups of 50, one for thex-> axis and
the>
> other for the y-axis, we
can't get the whole picture.the >
first> >
stock>
> (AAPL) has its
correlation only measured againststocks
50-> 99(JDSU->
> YHOO), but not for
example against ADBE or ADCT.>
> > thanks to posting
your code i am beginning tounderstand > the
logic>
> of looping better, so i
just changed some numbers tohave > the
loop> > go>
> through ALL possible
combinations. it takes slightlylonger >
(instead>
> of 50*50=2500 it's
100*100=10000 calculations) and of > course it
has>
> quite a lot of duplicate
results, but i think it isthe > only way
to>
> calculate all
correlations.>
> > also, i changed the
code from absolute to relative >
correlation,>
> which gives different
results.>
>
>>
> > what do you
think?>
>
>>
> >
dirk>
>
>>
>
>>
>
>>
> > // Exploration N100
relative Correlation table>
>
>>
> >
Buy=Sell=Short=Cover=0;>
>
>>
> > StkNum =
Status("StockNum");>
>
>>
> > Filter =
Status("LastBarInTest") AND StkNum < 100;>
>
>>
> >
AddTextColumn(Name(),"Ticker",1.0);>
>
>>
> >
SetOption("nodefaultcolumns",1);>
>
>>
> > n =
StkNum;>
>
>>
> > #include
<NtoN100Ticker.afl>>
>
>>
> > Ticker1 =
Ticker;>
>
>>
> > C1 =
ROC(Foreign(Ticker1,"C"),1);>
>
>>
> >
for(m=1;m<=99;m++)>
>
>>
> >
{>
>
>>
> >
n=m;>
>
>>
> > #include
<NtoN100Ticker.afl>>
>
>>
> > Ticker2 =
Ticker;>
>
>>
> > C2 =
ROC(Foreign(Ticker2,"C"),1);>
>
>>
> > Corr =
Correlation(C1, C2, 8 );>
>
>>
> > Color =
IIf(Corr>0.7,8,4); // Add colors to make aheat
> map>
>
>>
> >
AddColumn(Corr,Ticker,1.3,1,Color);>
>
>>
> >
}>
>
>>
>
>>
> > -----
Original Message ----->
> >
From: Herman vandenBergen>
> > To:
amibroker@xxxxxxxxxxxxxxx>
> > Sent:
Wednesday, November 26, 2003 11:43
PM>
> > Subject:
RE: [amibroker] to TOMASZ: how to loop
> through a
list>
> of tickers
?>
>
>>
>
>>
> > A slight
oversight in my previous code, you CANlist
> tickers by>
> name (no string array
needed) in the left most column >
with the>
> slightly different code
below. Here is a fragment ofthe >
table.>
> Include file can be found
in previous post.>
>
>>
>
>>
>
>>
> > // N100
Correlation table>
> >
Buy=Sell=Short=Cover=0;>
> > StkNum =
Status("StockNum");>
> > Filter =
Status("LastBarInTest") AND StkNum < 50;>
> >
AddTextColumn(Name(),"Ticker",1.0);>
> > n =
StkNum;>
> > #include
<NtoN100Ticker.afl>>
> > Ticker1 =
Ticker;>
> > C1 =
Foreign(Ticker1,"C");>
> >
for(m=50;m<=99;m++)>
> >
{>
> >
n=m;>
> >
#include <NtoN100Ticker.afl>>
> >
Ticker2 = Ticker;>
> > C2
= Foreign(Ticker2,"C");>
> >
Corr = Correlation(C1, C2, 8 );>
> >
Color = IIf(Corr>0,8,4); // Add colors to makea
> heat map>
> >
AddColumn(Corr,Ticker,1.3,1,Color);>
> >
}>
>
> -----Original
Message----->
> > From: dirk
schreiber
[mailto:tianatrading@xxxx]>
> > Sent: November 27,
2003 2:03 AM>
> > To:
amibroker@xxxxxxxxxxxxxxx>
> > Subject: [amibroker]
to TOMASZ: how to loopthrough 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 whati
> asked is>
> possible and if you could
indicate me the right way to
> code>
> this
??>
>
>>
>
> thank you,>
>
>>
>
> dirk>
>
>>
>
> -----
Original Message ----->
>
>
From:
dirk
schreiber>
>
> To:
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 itpossible
> to>
> calculate all
correlations of the stocks constituting
> the>
> nasdaq100 in one
scan?>
>
> my code below will
explore thecorrelations
> of IBM> >
with>
> the other 99 constituents
of my nasdaq100watchlist.
> is there> >
a>
> way in afl to tell
amibroker to first
calculatethese>
> correlations for one
stock, then go to the next anddo the> >
same>
> there and so forth, so
that i could find out the 10highest>
> 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="IBM";>
>
>>
> >
x=Foreign(pair,"C");>
>
>>
> >
y=C;>
>
>>
> >
xpc=ROC(x,1);>
>
>>
> >
ypc=ROC(y,1);>
>
>>
> >
Graph0=Correlation(xpc,ypc,20);>
>
>>
> >
Graph1=Correlation(xpc,ypc,200);>
>
>>
> >
Filter=Graph0>0.7 AND
Graph1>0.5;>
>
>>
> >
AddColumn(Graph0,"Cor20",1.2);>
>
>>
> >
AddColumn(Graph1,"Cor200",1.2);>
>
>>
> >
AddColumn(Graph0+Graph1,"total",1.2);>
>
>>
> >
Buy=0;>
>
>>
>
>>
>
>>
>
>>
>
>>
>
>
----- Original Message ----->
>
>
From: dirk
schreiber>
>
> To:
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 theideas
> behind>
> pair trading, reading the
interesting posts by yuki
> a few>
> months ago and writing
some code.>
>
> here is where i'm
stuck: when
icalculate>
> correlation, price ratio
and other things like beta
> ratio it>
> is my understanding that
when scanning my database ican >
only>
> compare one stock at a
time with the rest of myuniverse. -->
is>
>
it possible to calculate all
correlationsbetween > all
stocks>
> in one
scan?? i know that with big
groupsthis > would
mean>
> millions
of calculations, but for a
group likethe > n100
this>
> should be
possible?>
>
> can this be done by
some sort
ofloop?>
>
> i searched the mailing
list archiveand
> found only>
> one hint by DT, talking
about maybe using something
> like>
> Status("STOCKNUM") ==
0 , but i could
notwork > that
out> > ...>
>
>>
>
> any help
is
appreciated,>
>
> thanks
in
advance,>
>
>>
>
> dirk> >
> Yahoo! Groups Sponsor
>
ADVERTISEMENT>
>
> >
> Send BUG REPORTS to bugs@xxxx> Send
SUGGESTIONS to suggest@xxxx>
-----------------------------------------> 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
Yahoo! Terms ofService.Send 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
Yahoo! Groups Links
To visit your group on the web, go to:<A
href="">http://groups.yahoo.com/group/amibroker/
To unsubscribe from this group, send an email to:<A
href="">amibroker-unsubscribe@xxxxxxxxxxxxxxx
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
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
Yahoo! Groups Sponsor
ADVERTISEMENT
Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|