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

Notification

Icon
Error

Options
Go to last post Go to first unread
gawdib  
#1 Posted : Friday, March 3, 2006 5:13:10 AM(UTC)
gawdib

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 11/10/2005(UTC)
Posts: 31

I am puzzeled by how the Latch Dll works. The following seems to indicate that this dll has eliminated the need for prev and initialization variables etc. However, I cannot see how it is doing a latch. Z:= ExtFml(“forum.Latch",c>mov(c, 20,s),c< mov(c, 5,s),0,0); z What shows up on a chart of this "z indicator" is a 1 as long as c>mov(c, 20,s), even tho the exit criteria have been met. The indicator goes to 0 only when c>mov(c, 20,s) is no longer true. How could that be? What is the latch function supposed to accomplish? thanks, Geo The below is what is in the manual.
"Of course, the whole purpose of this latch is not to have to deal these issues any more. The work that Patrick has done alleviates the need for all this unnecessary code and when the same result is achieved with the new, extremely simple way to do the same thing:" .... Now the criteria has been defined, we call the external formula to only trigger a BUY signal if (and only if) a buy signal has not been previously set without a sell signal, or the last signal was a sell signal. Read both cases as, we are not already in a long trade. The sell signal will only set if we are in a long trade. Z:= ExtFml(“forum.Latch",LE,LX,0,0); EnterLong:=Z = 1 AND Ref(Z,-1) <> 1; ExitLong:=Z = 0 AND Ref(Z,-1) = 1; We now want to plot these on a chart. One of the easiest ways is to just plot: EnterLong; ExitLong; If we plot this on a chart, the indicator value be zero, except when a buy or sell signal is generated and the value will be one. (Its handy to plot this as a histogram) But how do we tell the two signals a part? We could just keep track of which signal occurred when, but it might get a little confusing, so try plotting this instead: EnterLong-ExitLong; This indicator line will be +1 when a buy signal is generated and -1 when a sell signal is generated. You can now tell at a glance which signal is which. Long Trade Code Summary: fastMA:=Mov(C,7,S); slowMA:=Mov(C,21,S); LE:=Cross(fastMA,slowMA); LX:=Cross(slowMA,fastMA); Z:= ExtFml(“forum.Latch",LE,LX,0,0); EnterLong:=Z = 1 AND Ref(Z,-1) <> 1; ExitLong:=Z = 0 AND Ref(Z,-1) = 1; EnterLong-ExitLong; You can follow exactly the same process for short trading. Based on the 'discovery' by Roy Larsen, we have to initialize the system to trigger on the first trades. I used the code below: fastMA:=Mov(C,7,S); slowMA:=Mov(C,21,S); LE:=Cross(fastMA,slowMA); LX:=Cross(slowMA,fastMA); Z:= ExtFml(“forum.Latch",LE,LX,0,0); NL:=Z=1 AND Ref(Z,-1)<>1; XL:=Z=0 AND Ref(Z,-1)=1; LongTrade:=BarsSince(NL OR (Cum(NL>-1)=1))<BarsSince(XL OR Cum(XL>-1)=1); LongTrade; This code will return a value of one when in a long trade and zero when out. Of course, the whole purpose of this latch is not to have to deal these issues any more. The work that Patrick has done alleviates the need for all this unnecessary code and when the same result is achieved with the new, extremely simple way to do the same thing: fastMA:=Mov(C,7,S); slowMA:=Mov(C,21,S); LE:=Cross(fastMA,slowMA); LX:=Cross(slowMA,fastMA); ExtFml(“forum.Latch",LE,LX,0,0); We can see now the power in Patrick's solution... and again thank him for his efforts.
mstt  
#2 Posted : Friday, March 3, 2006 5:26:43 AM(UTC)
mstt

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)
Gawdib This tool is only a replacement for simple latches, not PREV-based latches. It was never designed to manage an exit based on the some aspect of the entry. Entries and exits must be independant of each other. There'll be more on the Forum Latch function in the March issue of MSTT. 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.