in Search

Latch This

Last post 04-26-2008, 21:55 by wabbit. 1 replies.
Sort Posts: Previous Next
  •  04-26-2008, 21:05 27039

    Latch This

    Ciao,

    Why won't this work? OK, I'm developing a system where I need to track system states to keep indicators from cluttering my chart. These "latches" will not work for me so I put together this proof of concept piece to try to debug, pretty much stright out of the manual. This system will display one enter signal, then one short enters, then ,,,, nothing! Can someone who knows this function tell me what's wrong with my code?

    Enter Long
    fastMA:=Mov(C,7,S);
    slowMA:=Mov(C,21,S);
    stochInd:=Stoch(5,3);
    LE:=Cross( fastMA, slowMA )
    OR
    Cross(stochInd,20);
    SE:=0;
    LX:=0;
    SX:=0;
    B:= ExtFml("forum.Latch",LE,LX,SE,SX);
    B = 1 AND Ref(B,-1) <> 1

    Enter Short
    fastMA:=Mov(C,7,S);
    slowMA:=Mov(C,21,S);
    stochInd:=Stoch(5,3);
    SE:=Cross( slowMA, fastMA )
    OR
    Cross(80, stochInd );
    LE:=0;
    LX:=0;
    SX:=0;
    B:= ExtFml("forum.Latch",LE,LX,SE,SX);
    B = -1 AND Ref(B,-1) <> -1

    Exit Long
    stochInd:=Stoch(5,3);
    LX:=Cross(90,stochInd);
    LE:=0;
    SE:=0;
    SX:=0;
    B:= ExtFml("forum.Latch",LE,LX,SE,SX);
    B = 0 AND Ref(B,-1) = 1

    Exit Short
    stochInd:=Stoch(5,3);
    SX:=Cross(stochInd,10);
    LE:=0;
    LX:=0;
    SE:=0;
    B:= ExtFml("forum.Latch",LE,LX,SE,SX);
    B = 0 AND Ref(B,-1) = -1

    I appreciate the aid,

    Garp

    woof woof

     

     

     

  •  04-26-2008, 21:55 27041 in reply to 27039

    Re: Latch This

    Garp,

    I don't think you have fully grasped the "latch" concept, so I hope the explanations below will help...

    Code:

    {Enter Long}
    fastMA:=Mov(C,7,S);
    slowMA:=Mov(C,21,S);
    stochInd:=Stoch(5,3);
    LE:=Cross( fastMA, slowMA )
    OR
    Cross(stochInd,20);
    SE:=0;
    LX:=0;
    SX:=0;
    B:= ExtFml("forum.Latch",LE,LX,SE,SX);
    B = 1 AND Ref(B,-1) <> 1

    This will plot a value of 1 on the first instance when the LE condition is true.  As you never exit this "trade" there will only ever be one spike.  The latch thinks it is already in a long trade and will not give any more signals until this trade is exited.

    Code:

    {Enter Short}
    fastMA:=Mov(C,7,S);
    slowMA:=Mov(C,21,S);
    stochInd:=Stoch(5,3);
    SE:=Cross( slowMA, fastMA )
    OR
    Cross(80, stochInd );
    LE:=0;
    LX:=0;
    SX:=0;
    B:= ExtFml("forum.Latch",LE,LX,SE,SX);
    B = -1 AND Ref(B,-1) <> -1

    This will plot a value of 1 on the first instance when the SE condition is true.  The logic is the same as for the LE (above).

    Code:

    {Exit Long}
    stochInd:=Stoch(5,3);
    LX:=Cross(90,stochInd);
    LE:=0;
    SE:=0;
    SX:=0;
    B:= ExtFml("forum.Latch",LE,LX,SE,SX);
    B = 0 AND Ref(B,-1) = 1

    As no long trades are ever entered, all the exit signals are ignored.

    Code:

    {Exit Short}
    stochInd:=Stoch(5,3);
    SX:=Cross(stochInd,10);
    LE:=0;
    LX:=0;
    SE:=0;
    B:= ExtFml("forum.Latch",LE,LX,SE,SX);
    B = 0 AND Ref(B,-1) = -1

    As no short trades are ever entered, all the exit signals are ignored.

    As has been mentioned before, the Forum.dll latch is a very generic system and does not necessarily match every trader's logic.  You can "see" how the latch performs by viewing the truth table at http://forum.equis.com/forums/permalink/16453/16453/ShowThread.aspx#16453



    Hope this helps.

    wabbit Big Smile [:D]

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status : wabbit.com.au SkyPE online status
    My SkyPE account : wabbit.com.au

View as RSS news feed in XML