logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
mahshah  
#1 Posted : Monday, May 7, 2012 7:51:48 PM(UTC)
mahshah

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 5/8/2012(UTC)
Views messages in topic : 3

Hello,

I basically want to run a correlation between two stocks ONLY on periods where the return of the first stock is positive- that is, if I have the data set:

Period Return_1
1 -2
2 8
3 -4
4 3

I would correlate Return_1 with another return using only periods 2 and 4.

I'm new to Metastock but I can't find any information on this... the "filter" tab only seems to be for filtering out securities, not filtering out periods. Can this be done in metastock?

Thanks!


wabbit  
#2 Posted : Monday, May 7, 2012 9:15:09 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Huh?

If you want to create a data array containing only the positive values, this cannot be in MS, you'd have to do the correlation externally. If you just want to replace any negative values with zero and correlate the two arrays:

Code:

prd:=20;
shift:=0;

indep:=roc(c,1,%);
dep:=security(wherever,roc(c,1,%));

indep:=(indep>0)*indep;

dep:=(dep>0)*dep;

{plot}
correl(indep,dep,prd,shift);


RTFM and do the exercises in the free Equis formula primer; you'll learn what the explorer is, what the filter does and how to use them with code you write yourself.



wabbit [:D]

Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.