Rank: Member
Groups: Registered, Registered Users Joined: 1/5/2006(UTC) Posts: 14
|
I'm trying to test reliability of various entry strategies and need help coding the exits.
For instance, I want the system tester to exit "X" number of days after an entry; I can't seem to figure out how to code the exit. How do I tell the system tester to exit the position 5 days after the entry (or 2 days, 10 days, etc.)?
Any help would be appreciated!
Cheers,
Thom
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Thom
Here's a formula you could use to provide a timed exit. Typically you would define conventional entry and exit (if used) signals than then apply them to this PREV latch as the "N" and "X" variables.
D:= 5; {exit delay periods};
N:=Fml("your entry formula"); {entry signal here}
X:=0; {Fml("your conventional exit formula");} {exit signal here}
R:=If(PREV<=0,N, X OR If(BarsSince(PREV<=0)>=D,-PREV,PREV));
Exit:=R<0;
Exit
There's also a Simulation function that can be used to time the age of the position and generate an exit. Simulation functions tend to be even more resource hungry than PREV so the EST will also run slowly when they are used.
Another common method is to use a Stop not reaching an extreme dollar or percentage gain or loss within a specified number of bars.
Roy
MetaStock Tips & Tools
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 1/5/2006(UTC) Posts: 14
|
Thanks Roy.
I haven't ventured into the area of "defining" variables in formulas so I'm not sure I completely understand the formula you've provided, but I'll try to work through it.
I see that "R" is defined with the inclusion of "X", and that "X" is defined as my "conventional exit formula"; however, there is no exit formula: the exit is simply "X" number of days from the entry and this is the area that's being problematic. If there is an exit formula to define as "X", an example would be, "exit 5 days after entry". This is the formula I can't figure out. So, as is, I can't define "X". Any thoughts?
Thanks,
Thom
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi Thom
Leave "X" as it is (as presented it's defined as always being false or zero), or you could remove all references to "X" be removing the definition line and also removing "X OR" from the "R" variable definition. With "X" defined as always false or removed altogether the "R" variable acts as a PREV latch that resets when "time since entry" equals the exit delay value.
Try this ...
D:= 5; {exit delay periods};
N:=Fml("your entry formula"); {entry signal here}
X:=0;
R:=If(PREV<=0,N, X OR If(BarsSince(PREV<=0)>=D,-PREV,PREV));
Exit:=R<0;
Exit
Or this ...
D:= 5; {exit delay periods};
N:=Fml("your entry formula"); {entry signal here}
R:=If(PREV<=0,N,If(BarsSince(PREV<=0)>=D,-PREV,PREV));
Exit:=R<0;
Exit
Roy
MetaStock Tips & Tools
|
|
|
|
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.