Discussions
»
Product and Service Development
»
Formula Assistance
»
find out the correlation from each trading days compare with the whole month
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 12/3/2010(UTC) Posts: 3
|
I want to find out the correlation from each trading days compare with the whole month, for example:
4/10/2010 is 40 days before,
Hang seng index in Oct:
Open: 22542.36
Close: 23096.32
+2.4%
for day1 (4/10/2010)
open: 22542.36
close: 22618.66
+0.34%
day:=((Ref(C,-40)-Ref(O,-40))/Ref(O,-40))*100;
mth:=((Ref(C,-21)-Ref(O,-40))/Ref(O,-40))*100;
Correl(day,mth,0,0)
I have tried my best to modify since I am still a newbie :P, but it doesn't work :(
Do anyone have any good ideas to have better coding?? or make it more convenience?
Really Thanks!
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
Maybe the following code will give you some ideas:
mm:=4;
dds:=1;
dde:=30;
yy:=2010;
a1s:=If(Month()=mm AND Year()=yy AND
DayOfMonth()=dds,1,0);
a1e:=If(Month()=mm AND Year()=yy AND
DayOfMonth()=dde,1,0);
a2:=ValueWhen(1,a1s=1,O);
a3:=ValueWhen(1,a1e=1,C);
{---------------------------} b1:=LastValue(((a3-a2)/a2)*100);
b2:=((C-a2)/a2)*100;
b3:=Correl(b1,b2,5,10); b3
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 12/3/2010(UTC) Posts: 3
|
Thx. Johnl!
but I don't understand how could u define the correl function with 5 days period and 10 days shift..... actually I don't clear how to set the shift period
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
The definition of the correl() function per the user manual is the shift of the second variable before comparison to the first to see if there is a "predictable" sync ( one leading the other). Play around with the shift function is the best way to get a feel for what it does.
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 12/3/2010(UTC) Posts: 3
|
:(
I have tried lots of modifing the code but still has error: Period value out of valid range in Correl() function.
can anyone help??
And beside this, I want to ask any one bought the book: Metastock programming study guide, which is from Australia, is it good for newbie to start learning metastock programming?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
You might try posting your code.
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
find out the correlation from each trading days compare with the whole month
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.