Rank: Newbie
Groups: Registered, Registered Users Joined: 12/18/2007(UTC) Posts: 5
|
All, in the June 2010 edition of TASC, Walter Downs speaks of his Forex Gambit trading system.
I've started in a very elementary fashion what some of the code may look like, but so far, Metastock hasn't liked it a bit. Please help.
Buy : Buy two lower lows and a closing price that is greater than the midpoint of the bar and is above the SMA
My code:
L<(Ref(L,-1) AND Ref(L,-1)<Ref(L,-2)) AND ((H-L)/2)> Mov(C,30,S) AND C>((H-L)/2)
Exit Long: When a bar occurs whose range is greater than the previous three ranges and whose close is in the top 10% of the bar, exit a long position on the first closing price that is lower than the previous closing price OR exit after 16 days.
My code:
(((H-L)>Ref((H-L),-1) AND (H-L)>Ref((H-L),-2) AND (H-L)>Ref((H-L),-3) AND C>Mul((H-L) ,(.9))) AND C< Ref(C,-1))
OR
BarsSince((L<(Ref(L,-1) AND Ref(L,-1)<Ref(L,-2))
AND
((H+L)/2)> Mov(C,30,S)
AND
C>((H+L)/2)))=16
I'm pretty elementary when it comes to programming, so please give me any pointers you can.
Thanks.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
Write your code like this and it is easier to see what is going on.
a1:=(L<Ref(L,-1))*(Ref(L,-1)<Ref(L,-2)); a2:=((H-L)/2)>Mov(C,30,S); a3:=C>((H-L)/2); a1;a2;a3;
Color each plot a different color and modify the code accordingly.
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 12/18/2007(UTC) Posts: 5
|
Thanks.
I had to modify the line a2 and a3.
a1:=(L<Ref(L,-1))*(Ref(L,-1)<Ref(L,-2));
a2:=(H-((H-L)/2)>Mov(C,30,S));
a3:=C>(H-((H-L)/2))
Now, I think I can set up an advisor to say if buy if a1+a2+a3 = 3.
Off to find someone else's idea to copy, I suppose.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
You could also watch the videos available through the forum to watch how the plug-in folks approach putting trading strategies together for ideas.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/25/2010(UTC) Posts: 55
|
Is the * in a1 equivalent to "and"?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/25/2010(UTC) Posts: 55
|
I've never seen * be anything but a multiplier; what about this line of code relegates it to "and?"
Thanks.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 12/14/2009(UTC) Posts: 140 Location: Austria
|
it's still a mulitplier but multiplying with 0/1 values is the same as an AND
1 * 1 = 1 1 AND 1 = 1 1 * 0 = 0 1 AND 0 = 0 0 * 1 = 0 0 AND 1 = 0
0 * 0 = 0 0 AND 0 = 0
+ can be used as an OR
1 + 1 = 2 (which is in metastocks if you use it logical = 1) 1 OR 1 = 1 1 + 0 = 1 1 OR 0 = 1 0 + 1 =1 0 OR 1 = 1 0 + 0 = 0 0 OR 0 = 0
best regards ts
|
|
|
|
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.