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

Notification

Icon
Error

Options
Go to last post Go to first unread
disi  
#1 Posted : Sunday, January 29, 2012 12:55:11 PM(UTC)
disi

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 9/5/2011(UTC)
Posts: 5

Hello guys,

Can you help me find solution to my coding problem? In summary:

Open buy is when:

x or y

now...I would like to close that position in one of two ways("z" or "c") - depending in which way Buy was open...

so for example if "x" was reason for opening Buy, system should close it now only when "z" occurs. And if it was bought with "y" condition "c" must happen to close it.

Any idea how to do it? Metastock has 4 different tabs(one for each transaction). If whole code for system could be written only in one tab(conditions for all Entry/Close order in one listing/page) that would seem possible. Any idea how to do it in Metastock? Maybe it would be easier in VTS addon?
wabbit  
#2 Posted : Sunday, January 29, 2012 5:12:50 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)
You could use a "simple" PREV based latch, something like:

Code:

N1:={entry condition 1};
N2:={entry condition 2};

X1:={exit condition 1};
X2:={exit condition 2};

tr:=
if(prev=0,
if(N1,1,if(N2,2,0)),
if( (prev=1 AND X1) or (prev=2 AND X2), 0, prev)
);

{plot}
tr;


What this code doesn't do though, is deal with the situation when both entry signals occur on the same bar in which case I assume it would be a race to which exit condition triggers first? (Priority is given to N1).


Hope this helps.

wabbit [:D]


disi  
#3 Posted : Tuesday, January 31, 2012 4:16:02 AM(UTC)
disi

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 9/5/2011(UTC)
Posts: 5

Thank you wabbit - that is really smart and I would never came to it on my own! :)
Actully my system is more complicated than described(it is not reverse system - at least in second "condition", so it has more variables than 4) but with this idea I think I will figure how to do it one or the other way.

Thanks again!
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.