PureBytes Links
Trading Reference Links
|
<FONT face=Arial color=#0000ff
size=2>Jason,
You
will be up to speed in no time. I cannot program in C++ but have read several
fine examples posted here to learn the basic concept, and asked a lot of
questions. Just spend some time experimenting, it is not nearly as complicated
as it looks at first blush.
Regards,
Jayson
<FONT face=Tahoma
size=2>-----Original Message-----From: Jason Hart
[mailto:jhart_1972@xxxxxxxxx]Sent: Friday, January 23, 2004 10:04
AMTo: amibroker@xxxxxxxxxxxxxxxSubject: RE: [amibroker]
Correlation Studies
Jayson,
This is fantastic!! Thanks for your help with this. I have no
idea how you came up with this formula but it is pretty consistent with what I
expected in looking at numerous charts. Just curious, how long did it take
you to learn all this - I just started studying c++ to learn more about looping
and the iif function, hopefully by summertime I'll be more profecient.
Thanks again
Best,
JasonJayson <jcasavant@xxxxxxxxxxx>
wrote:
<BLOCKQUOTE class=replbq
>
<FONT face=Arial color=#0000ff
size=2>Jason,
<FONT face=Arial color=#0000ff
size=2>
You
could perhaps use looping to find the correlation on a given day, accumulate
that data then divide the sum by the periods to find an average. By that I
mean sum only the correlation figures on down index days for one study and up
days for another. The code below is adapted from a volume study I use but may
at the least lead you in a direction......
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>Regards,
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>Jayson
<SPAN
class=252415104-23012004><FONT face=Arial color=#0000ff
size=2>
<SPAN
class=252415104-23012004><FONT color=#282828
size=2>
Pds=<FONT
color=#0000ff>Param(<FONT
size=2>"PDS",21<FONT
size=2>,5,<FONT
size=2>100,1<FONT
color=#282828 size=2>);
x=<FONT
color=#0000ff>Foreign(<FONT
size=2>"!comp",<FONT
size=2>"Close"<FONT face=Arial
color=#0000ff>);
up=x><FONT
face=Arial>Ref<FONT
size=2>(x,-1<FONT color=#282828
size=2>);
dn=x<<FONT
face=Arial>Ref<FONT
size=2>(X,-1<FONT color=#282828
size=2>);
test=<FONT
color=#0000ff>Correlation(<FONT
size=2>C<FONT face=Arial
color=#0000ff>,x,pds);
x = <FONT face=Arial
color=#0000ff size=2>0<FONT face=Arial
color=#0000ff>;
y = <FONT face=Arial
color=#0000ff size=2>0<FONT face=Arial
color=#0000ff>;
for<FONT
color=#0000ff>( i = 1; i
< pds+1<FONT color=#282828
size=2> ; i++ )
{
x = x + <FONT face=Arial
color=#0000ff size=2>ValueWhen<FONT
face=Arial color=#0000ff>( up, test,i);
y = y + <FONT face=Arial
color=#0000ff size=2>ValueWhen<FONT
face=Arial color=#0000ff>( dn, test,i);
}
vp=x-y;<FONT
color=#0000ff size=2>
Plot<FONT color=#282828
size=2>(x/pds,"Up day corr"<FONT
color=#282828 size=2>,5<FONT
color=#282828 size=2>,1<FONT
color=#282828 size=2>);<FONT
color=#0000ff size=2>
Plot<FONT color=#282828
size=2>(y/pds,"Dn Day corr"<FONT
color=#282828 size=2>,4<FONT
color=#282828 size=2>,1<FONT
color=#282828 size=2>);
Title=<FONT
color=#0000ff size=2>EncodeColor<FONT color=#282828
size=2>(colorBrightGreen<FONT color=#282828
size=2>)+"Up Day Correlation = "<FONT
color=#282828 size=2>+WriteVal<FONT
color=#282828 size=2>(x/pds,1.2<FONT
color=#282828 size=2>)+<FONT color=#0000ff
size=2>EncodeColor(<FONT
size=2>colorRed)+<FONT
color=#ff00ff size=2>", Down Day Correlation = "<FONT color=#282828
size=2>+WriteVal<FONT color=#282828
size=2>(y/pds,1.2<FONT color=#282828
size=2>)+"\n "<FONT color=#282828
size=2>+EncodeColor<FONT
color=#282828 size=2>(colorWhite<FONT
color=#282828 size=2>)+WriteIf<FONT
color=#282828 size=2>(x/pds>y/pds,<FONT color=#ff00ff
size=2>"Currently "+<FONT
color=#0000ff size=2>Name()+<FONT
color=#ff00ff size=2>" is better correlated to the index on UP
days",<FONT color=#ff00ff
size=2>"Currently "+<FONT
color=#0000ff size=2>Name()+<FONT
color=#ff00ff size=2>" is better correlated to the index on DOWN
days");
GraphXSpace=<FONT
color=#ff00ff size=2>5<FONT color=#282828
size=2>;<FONT
color=#0000ff>
<FONT face=Tahoma
size=2>-----Original Message-----From: Jason Hart
[mailto:jhart_1972@xxxxxxxxx]Sent: Thursday, January 22, 2004
8:12 AMTo: amibroker@xxxxxxxxxxxxxxxSubject: RE:
[amibroker] Correlation Studies
Jayson,
I figured that part out, where I'm stuck is how to treat the cumulative
results. If day 1 is true then what value is given to day one....then
day 2 then day 3, etc? What I'm trying to do is construct two
separate correlation studies - one compares the base stock to days when the
Nasdaq is up and the other compares the base stock to the Nasdaq when the
Nasdaq is down. I suspect they will be pretty jagged because there
will be day when they do not budge because of false results - perhaps I'll
have to use a MA on them.
The rationale behind this applies to sector/market
laggards. They'll demonstrate a low correlation to the up days,
since they are lagging, and if they have a high correlation to the Nasdaq on
the Nasdaq down days that's a red flag - perhaps a sign to short the weak
stocks
Thanks for the reply
Jason Jayson
<jcasavant@xxxxxxxxxxx> wrote:
<BLOCKQUOTE class=replbq
>
<FONT face=Arial color=#0000ff
size=2>Jason,
<FONT face=Arial color=#0000ff
size=2>nasup and nasdown return either a true or false result. If
x>=ref(x,-1) then nasup returns 1 if not it returns 0. The same is true
for nasdown.so in your code....
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>y= the correlation of the close of !comp and 1.
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>I assume what you are after is trying to find stocks that are
highly correlated with the index. You could do this with a simple
correlation study as an exploration
<FONT face=Arial color=#0000ff
size=2>
<FONT color=#282828
size=2>
x=<FONT
size=2>Foreign("!comp"<FONT
size=2>,"Close"<FONT
color=#282828><FONT face=Arial color=#0000ff
size=2>);<FONT face=Arial
color=#0000ff size=2>
Filter<FONT
face=Arial>=<SPAN
class=253491904-22012004>1;<FONT
color=#282828>
AddColumn<FONT
face=Arial>(<FONT
color=#0000ff>Correlation(<FONT
color=#282828>x,C<FONT
color=#282828>,21<FONT
color=#282828>),<FONT
color=#ff00ff>"Correlation");<SPAN
class=253491904-22012004>//measures the correlation over the last 21 bars,
adjust as needed
<FONT
face=Arial>
<FONT face=Arial
color=#282828 size=2>Run the exploration for n=1 bar then click the
correlation header to sort. This will show you how well the individual
stock correlates to the index. You could plot the same data by
adding
<SPAN
class=253491904-22012004>
<FONT color=#0000ff
size=2>x=<FONT
size=2>Foreign("!comp"<FONT
size=2>,"Close"<FONT
color=#282828>);
Plot<FONT
color=#282828 size=2>(<FONT color=#0000ff
size=2>Correlation(x,<FONT
size=2>C<FONT color=#282828
size=2>,21<FONT color=#282828
size=2>),""<FONT color=#282828
size=2>,4<FONT color=#282828
size=2>,1<FONT
color=#282828 size=2>);
GraphXSpace<FONT
face=Arial>=<FONT
size=2>10<FONT face=Arial
color=#0000ff>;
Regards,
Jayson
<FONT face=Tahoma
size=2>-----Original Message-----From: Jason Hart
[mailto:jhart_1972@xxxxxxxxx]Sent: Wednesday, January 21, 2004
3:23 PMTo: amibroker@xxxxxxxxxxxxxxxSubject:
[amibroker] Correlation Studies
I was wondering if anyone has experimented with correlation studies
of a stock relative to an index on a day when the index is up and when the
index is down. Since I trade mostly Nasdaq stocks I'm
trying to put together an indicator that shows the correlation of a stock
when the Nasdaq is up and when the Nasdaq is down. I'm
having quite a bit of trouble since I haven't really used the IIF
function and I'm not sure if I need to create composites. I put this
together so far but it is way off base (I'm afraid it's too simplistic!) -
what happens is both studies are the complete inverse of each other.
x=Foreign<FONT
size=1>("!comp"<FONT
size=1>,"Close"<FONT
size=1>);
Nasup = x >= Ref<FONT
size=1>(x,-1);
Nasdown = x < Ref<FONT
size=1>(x,-1<FONT
size=1>);
IIf(x> <FONT color=#0000ff
size=1>Ref(x,-<FONT color=#ff00ff
size=1>1),Nasup,Nasdown);
y= Correlation<FONT
size=1>(Nasup,C,100<FONT
size=1>);
z=Correlation<FONT
size=1>(Nasdown,C,100<FONT
size=1>);
Plot<FONT
size=1>(y,"Nasdaq Up Correl"<FONT
size=1>,3<FONT
size=1>,1<FONT
size=1>,1<FONT
size=1>,1<FONT
size=1>);
Plot(z,"Nasdaq
Down Correl",<FONT color=#ff00ff
size=1>4,<FONT color=#ff00ff
size=1>1,<FONT color=#ff00ff
size=1>1,<FONT color=#ff00ff
size=1>1);
Do you Yahoo!?Yahoo! Hotjobs: <A
href="">Enter
the "Signing Bonus" Sweepstakes 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@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.
Do you Yahoo!?Yahoo! SiteBuilder - Free web site building tool. <A
href="">Try
it! 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@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.
Do you Yahoo!?Yahoo! SiteBuilder - Free web site building tool. <A
href="">Try
it! 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.
|