Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 9/22/2005(UTC) Posts: 1
|
I have written an exploration, and am using a trailing stop of the prev two day low for an exit signal. My problem is, I don't want to trigger an exit signal unless I am in an active trade. So how can I evaluate the current bar, and be sure that I have previously entered a trade with an ENTER signal?
Any help is appreciated.
|
|
|
|
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)
|
Gary
There are at least three different ways you can approach this. Basically, you need a latch. A simple latch might do the trick - sample 1, or you might need a PREV based latch when an exit is conditional upon some factor relating to the entry - sample 2.
When I get a full drivers license for this site (and present levels of frustation suggest I may never bother to take the test) I might direct you to a DLL that Patrick has written to perform the latch function. With a bit of hunting you may be able to find it for yourself, but I'd suggest it would be worth your while to work out the mechanics of these two latch styles before moving on to a dll-based solution.
{Sample Trade Stop 1}
N:=Fml("Entry Binary"); {buy Fml() or variable}
X:=C<Ref(LLV(L,2),-1); {sell Fml() or variable}
I:=Cum(N+X>-1)=1;
R:=BarsSince(I+N)<BarsSince(I+X);
R=0 AND Alert(R,2);
{Sample Trade Stop 2}
N:=Fml("Entry Binary"); {buy Fml() or variable}
X:=0; {sell Fml() or variable}
R:=If(PREV<=0,N>0,If(X OR
C<Ref(LLV(L,2),-1) {OR any condition},-1,1));
R<0; {latch reset signal - delay as required}
Roy
www.metastocktips.co.nz
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 3/19/2005(UTC) Posts: 2,995
Was thanked: 14 time(s) in 10 post(s)
|
Are ya'll having a time of it finding Patric's latch? If so, it is permanently listed in the Download section: MetaStock Online Group Forum Index -> Forum Downloads -> Forum Dll ( Click here). His latch is a part of the ForumDll. Documentation available in the same place.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 3/19/2005(UTC) Posts: 2,995
Was thanked: 14 time(s) in 10 post(s)
|
Methods of stopping redundant signals are also discussed in the Forum FAQ. :D
|
|
|
|
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.