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

Notification

Icon
Error

Options
Go to last post Go to first unread
junkyard  
#1 Posted : Monday, November 2, 2009 6:31:33 PM(UTC)
junkyard

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 2/6/2009(UTC)
Posts: 3

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

johnl  
#2 Posted : Monday, November 2, 2009 7:31:05 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

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.



junkyard  
#3 Posted : Tuesday, November 3, 2009 3:30:29 PM(UTC)
junkyard

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 2/6/2009(UTC)
Posts: 3

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.


johnl  
#4 Posted : Tuesday, November 3, 2009 7:44:29 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

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
junkyard  
#5 Posted : Wednesday, November 4, 2009 12:20:37 PM(UTC)
junkyard

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 2/6/2009(UTC)
Posts: 3

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





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.