johnl wrote: 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.