in Search

EST Trailing Stop using Elder...

Last post 11-04-2009, 12:20 by junkyard. 4 replies.
Sort Posts: Previous Next
  •  11-02-2009, 18:31 31081

    EST Trailing Stop using Elder...

    I've been searching the forums attempting to find a resolution but seem to be dumbfounding myself on the crumbs looking for the whole piece.  I'm trying to run a simple system test to verify accuracy of my results before attempting something more complicated but am hung up on the stop. 

    The buy is simply:
    BUY: Cross(Mov(Close,13,e),Mov(Close,26,e))

    For the sell I am attempting to use the Chandelier formula of the Elder package "FmlVar("Elder - Chandelier Long","ATRDAYS")" into my sell code in order to have a trigger based upon the close being lower than the Chandelier exit since the highest high of the cross over.

    I've tried a number of approaches such as:
    SELL:
    C < FmlVar("Elder - Chandelier Long","ATRDAYS")
    to
    HI := HighestSince(1,Cross(Mov(Close,13,e),Mov(Close,26,e) ,C) - FmlVar("Elder - Chandelier Long","ATRDAYS");
    C<HI

    and think I may be mixing concepts in trying to code this am an looking for some direction.  I'm stumping myself and getting lost in the forum.dll and latches concepts that I've been coming across in my research and think I may be making things more difficult for myself than they need be.

    Thanks in advance,
    Michael

  •  11-02-2009, 19:31 31083 in reply to 31081

    Re: EST Trailing Stop using Elder...

         Here is the latch code you can read ( thanks to Wabbit)

    x:=BarsSince(a1)<BarsSince(a2); {latch}
    x:=Alert(x,2) AND a2; {first a2 after a1}
    x;

    create a1 and a2 variables using your criteria and see what you get.


     
  •  11-03-2009, 15:30 31087 in reply to 31083

    Re: EST Trailing Stop using Elder...

    johnl:
         Here is the latch code you can read ( thanks to Wabbit)

    x:=BarsSince(a1)<BarsSince(a2); {latch}
    x:=Alert(x,2) AND a2; {first a2 after a1}
    x;

    create a1 and a2 variables using your criteria and see what you get.


    I first coded the following and ran it a number of times on APPL (1000 period, Long Only, No Stops) to test the results.
    BUY:
    Cross(Mov(C,13,E),Mov(C,26,E))

    SELL:
    x:= BarsSince(Cross(Mov(Close,13,e),Mov(Close,26,e))) < BarsSince(HighestSince(1,Cross(Mov(Close,13,e),Mov(Close,26,e)),C));
    x:= Alert(x,2) and HighestSince(1,Cross(Mov(Close,13,e),Mov(Close,26,e)),C);
    x;

    If I am interpreting this correctly, the latch  assigns  false to x when the number of bars since the 13-26 crossover is less than the number of bars since the highest value after a 13-26 crossover. The second line I interpret as assign true to x when an alert of two false periods pass and the price value is the highest after the cross.  The last line clears x.

    Based on this assumption I attempted to use this as a template but still think I am far off since my results are still far from remotely accurate.

    There are three pieces of information that I need:
    A) The crossover
    B) The highest price value after the crossover
    C) The distance of the Chandelier exit at the time of the highest price

    This is what I came up with:
    SELL:
    x:= BarsSince(Cross(Mov(Close,13,e),Mov(Close,26,e))) < BarsSince(HighestSince(1,Cross(Mov(Close,13,e),Mov(Close,26,e)),C));
    x:= Alert(x,2) and HighestSince(1,Cross(Mov(Close,13,e),Mov(Close,26,e)),C);

    -- Attempt A --
    a1:=BarsSince(HighestSince(1,Cross(Mov(Close,13,e),Mov(Close,26,e)),C));
    a2:=HighestSince(1,Cross(Mov(Close,13,e),Mov(Close,26,e)),C);
    a3:= ExtFml( "Forum20.Ref", ExtFml( "ElderDisk.ChandelierLong",3 , 22)  , -a1);
    C <  a2-a3;
    x;

    -- Attempt B--
    a1:= HighestSince(1,Cross(Mov(Close,13,e),Mov(Close,26,e)),C);
    a2:=ValueWhen(1,HighestSince(1,Cross(Mov(CLOSE,13,E),Mov(CLOSE,26,E)),C),FmlVar("Elder - Chandelier Long","ATRDAYS")); {assign the value of a 3ATR,22PER Stop of the high after the cross}
    C<a1-a2;
    x;

    Addionally I've simply tried:
    Sell:
    HighestSince(1,Cross(Mov(CLOSE,13,E),Mov(CLOSE,26,E)),C) - ValueWhen(1,
    HighestSince(1,Cross(Mov(CLOSE,13,E),Mov(CLOSE,26,E)),C),FmlVar("Elder - Chandelier Long","ATRDAYS"))

    I feel like I'm coding what I intend to but the results say otherwise and I think I am just going in circles at this point.

    Regards,
    Michael.


  •  11-03-2009, 19:44 31089 in reply to 31087

    Re: EST Trailing Stop using Elder...

    How about this: I didn't have the Elder's stuff so i had  to make up my own.

    PLb := 22;
    Cof := 3;

    ChLg:=HHV(H,Plb) - (Cof*ATR(Plb));
    ChSh:=LLV(L,Plb) + (Cof*ATR(Plb));
    {--------------------------------}
    p1 := Mov(CLOSE,13,E);
    p2 := Mov(CLOSE,26,E);
    {-------------------------------}
    a1:=Cross(p1,p2);
    {-------------------------------}
    b1:=HighestSince(1,a1=1,Chlg);
    b2:=-Cross(b1,C);
    a1;b2;Chlg
  •  11-04-2009, 12:20 31102 in reply to 31089

    Re: EST Trailing Stop using Elder...

    Oddly enough the result of this code is the same as one of my early test, with a buy/sell on 4/11/06-4/12/06 and another on 4/12/09-4/18/09.  Luckily I picked a chart and time period with only two buy signals to practice on so the sell signals were obvious and easily focused in on.  So it got me thinking and tinkering and with some persistence I was able to fill some gaps in my knowledge and get the desired results... I think.

    Since my buy is triggered by a 13/26 EMA cross, the sell consideration is simply when the price closes below the chandelier so all I really need to resolve is the peak height of the trailing stop and when the price closes below.  Thus far the results are accurate.

    {Highest Value of the Chandelier exit after the CrossOver.}
    a1:=HighestSince(1,Cross(Mov(Close,13,E),Mov(Close,26,E)), ExtFml( "ElderDisk.ChandelierLong",3 ,22 ) );

    C < a1 





View as RSS news feed in XML