Rank: Advanced Member
Groups: Registered, Registered Users Joined: 2/19/2012(UTC) Posts: 106
Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
I am trying to write an exploration where I go long where there is a MACD bullish crossover below the zero line and that crossover is below the MACD histogram I came up with this
A:= (Mov(C,26,E)-Mov(C,12,E));
A<0 AND A<(A-Mov(A,9,E))<0 AND Cross(A,Mov(A,9,E))
I plugged it into the filter and ran the exploration but it is rejecting all the securities. Where am I going wrong?
Regards,
Dr.Chatterjee
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/29/2004(UTC) Posts: 1,394 Location: Glastonbury, CT
Was thanked: 2 time(s) in 2 post(s)
|
Code: your codeA:= (Mov(C,26,E)-Mov(C,12,E));
A<0 AND A<(A-Mov(A,9,E))<0 AND Cross(A,Mov(A,9,E))
a MACD is the fast Ma minus the slower ma yours is reversed
define the signal line as a variabledefine the Histogram as a variable
your error is in the second section of your code
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 2/19/2012(UTC) Posts: 106
Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
I tried your suggestion and came up with
A:= (Mov(C,12,E)-Mov(C,26,E)); B:=Mov(A,9,E); D:=A-B; A<0 AND A<D<0 AND Cross(A,B)
It still doesn't work. 100% rejection
Regards,
Dr.Chatterjee
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/29/2004(UTC) Posts: 1,394 Location: Glastonbury, CT
Was thanked: 2 time(s) in 2 post(s)
|
Code:A:= (Mov(C,12,E)-Mov(C,26,E));
B:=Mov(A,9,E);
D:=A-B;
A<0 AND A<D<0 AND Cross(A,B)
The value of A is the difference of the fast ma minus the slow MAThe value of B is the Ma of AThe value of D is the Histogram the difference of the A and BYour error occurs A<D<0 you can't write it that way, make sure that the values correspond to what you are looking for
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 2/19/2012(UTC) Posts: 106
Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
A:= (Mov(C,12,E)-Mov(C,26,E)); B:=Mov(A,9,E); D:=A-B; A<0 AND A<D AND Cross(A,B)
Works more or less---thank you---but I can't comprehend fully why I can't write A<D<0. What programming principle am I violating.?
Could you please explain?
Regards,
Dr.Chatterjee
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/29/2004(UTC) Posts: 1,394 Location: Glastonbury, CT
Was thanked: 2 time(s) in 2 post(s)
|
you need to connect them with AND , OR
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 10/17/2010(UTC) Posts: 3
|
Metastock Formula Language can compare only two values at a time. With 'A<D<0', you are trying to compare three values at a time, so is the error. You need to split it into two comparison conditions and use AND/OR function to join them.
Regards, sdg
|
|
|
|
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.