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

Notification

Icon
Error

Options
Go to last post Go to first unread
rdcarvajal  
#1 Posted : Wednesday, July 3, 2013 9:30:57 PM(UTC)
rdcarvajal

Rank: Newbie

Groups: Registered, Registered Users
Joined: 5/29/2013(UTC)
Posts: 3
Location: Sydney, Australia

Hi, I have moved my post here as this section looks more appropriate.

I have built an indicator based on one of Roy’s posts and it uses PREV-based latch. It is a long-only indicator and It consists of an entry trigger (a cross-over which I call “MainEntry”) and possible pyramid entries at entry price+4ATR(14) increments. So if a trend is long enough there could be several such pyramid entry points at entry+8ATR, then at 12ATR and so on. After “mainEntry” only pyramid trades are taken, so if there happens to be another cross-over during the up-trend, no action is taken. There is one exit for all long positions based on an ATR-trailing stop (from TradeSim). All of this works good and the indicator displays what I want perfectly (Pink line):
UserPostedImage
And this is the code for that indicator (Thanks to Roy):

Code:
 
Period:=14;

ARC:=4; { Average Range Constant }
Volatility:=ARC*ATR(Period);


A:=4*ATR(14);


N:= Fml( "111 5-20EMA with trend filter trial - BUY"); {primary entry signal}


N:=N*Alert(N=0,2); {leading edge of N signal}


X:=ExtFml( "TradeSim.TrailingStop", TRIGGER, LONG, Volatility, HIGH, LOW); { Trailing Stop Exit on the Long side }; {exit signal}


X:=X*Alert(X=0,2); {leading edge of X signal}


R:=If(0>=PREV, N*(C+A), {first entry}


If(C>PREV,(C+A), {pyramid entry}


If(X,-PREV,PREV))); {exit - negative spike}


Abs(R); {entry price target}
Now, the problem comes when I try to build an expert (and consequently a trade database for TradeSim). I have tried everything that I can think of (mainly modifying the "Abs(R);" part) but I can’t get rid of buy signals on every bar after "MainEntry". I just can’t figure out how to make each pyramid point become a single entry with no subsequent buy arrows until the next target is reached... I have the feeling that it must be something simple but it just got me stumped I'm afraid… Can someone point me in the right direction? Your help is appreciated. Thank you
oztrader  
#2 Posted : Thursday, July 4, 2013 8:45:11 PM(UTC)
oztrader

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 7/12/2007(UTC)
Posts: 134
Location: Perth Western Australia

Just a thought as I haven't had time to code & test this idea.

You should be able to eliminate the excess signals in the Expert by using Cum(Event) and Reset(X) to signal each time there is a change in the value of R and the any value of Cum(Event) > 1 will indicate a pyramid trade.

rdcarvajal  
#3 Posted : Friday, July 5, 2013 5:20:22 AM(UTC)
rdcarvajal

Rank: Newbie

Groups: Registered, Registered Users
Joined: 5/29/2013(UTC)
Posts: 3
Location: Sydney, Australia

oztrader wrote:
Just a thought as I haven't had time to code & test this idea.

You should be able to eliminate the excess signals in the Expert by using Cum(Event) and Reset(X) to signal each time there is a change in the value of R and the any value of Cum(Event) > 1 will indicate a pyramid trade.

You are a legend and a scholar! It worked perfectly. I also borrowed from one of Wabbit's post and added the following code to replace "Abs(R)"

Code:
 event:=R>Ref(R,-1)
AND R>1;

count:=Cum(event);

reset:=X OR
R=Ref(R,-1);

counter:=count-ValueWhen(1,reset,count);

{plot}

counter;
Now i have single arrow for each pyramid. Thank you, its good it came from a fellow aussie... Cheers,
oztrader  
#4 Posted : Friday, July 5, 2013 9:41:03 PM(UTC)
oztrader

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 7/12/2007(UTC)
Posts: 134
Location: Perth Western Australia

If you want to tag the Pyramid Trades separately from the Initial Trades in the expert advisor then try the following code. Just change the InitialEntry to suit your needs.

Code:

InitialEntry:=
Cross(Mov(C,5,E),Mov(C,20,E));
A:=4*ATR(14);
N:= InitialEntry;
N:=N*Alert(N=0,2);
X:=ExtFml( "TradeSim.TrailingStop",TRIGGER,LONG,A,HIGH,LOW);
X:=X*Alert(X=0,2);
R:=If(0>=PREV, N*(C+A), {first entry}
If(Cross(C,PREV),(C+A), {pyramid entry}
If(X,-PREV,PREV))); {exit - negative spike}
Pyramid:=
R>Ref(R,-1) AND R>C AND
Ref(R,-1)<>0;
{Plot}
Pyramid
Cheers,

rdcarvajal  
#5 Posted : Saturday, July 6, 2013 7:27:25 AM(UTC)
rdcarvajal

Rank: Newbie

Groups: Registered, Registered Users
Joined: 5/29/2013(UTC)
Posts: 3
Location: Sydney, Australia

oztrader wrote:

If you want to tag the Pyramid Trades separately from the Initial Trades in the expert advisor then try the following code. Just change the InitialEntry to suit your needs.

That was exactly what I was looking for... I want to use this to build a trade database in TradeSim. I got the same result with both formulas but yours is simpler. I want to use the "AltTrigger" for pyramiding in TradeSim and I think this will do the trick.

I worked on this for nearly 2 weeks to no avail...Cheers mate... Seriously, you are a legend!


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.