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

Notification

Icon
Error

Options
Go to last post Go to first unread
Flexi  
#1 Posted : Wednesday, March 2, 2011 4:37:35 AM(UTC)
Flexi

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/27/2006(UTC)
Posts: 135

How to code an indicator that plot the pnl of a trade on the buy signal bar? You have a code that give buy signal and the trade has 3 bars and exit on the third bar. The profit is +2%. Wanted to plot this +2% on the buy signal bar.
johnl  
#2 Posted : Thursday, March 3, 2011 6:56:51 PM(UTC)
johnl

Rank: Advanced Member

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

I've created indicators like below to see if an indicator is profitable instead of using
the system tester. This one sells on the signal's close and buys on the next day's
opening. You can modify as you like.

a1:=(your signal=1)*c;
a2:=ValueWhen(Ref(your buy signal=1,-1),O);
a3:=(a1-a2); {profit or loss}
a4:=cum(a3); (add em all up}
a4 {plot}



Flexi  
#3 Posted : Friday, March 4, 2011 2:21:13 AM(UTC)
Flexi

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/27/2006(UTC)
Posts: 135

johnl,

your code assuming the trade bar is 1 bar but individual trade differs on the trade bars. Some trade has 3 bars and exit some other has 16 bars and exit.

below is a code for calculating the trade pnl but the plot of the pnl is on the exit bar. do u know how to plot the pnl on the entry bar?

entry:=Cross(Mov(C,10,S),Mov(C,30,S));
exit:=Cross(Mov(C,30,S),Mov(C,10,S));

init:=Cum(IsDefined(entry+exit))=1;
flag:=ValueWhen(1,entry-exit<>0 OR init,entry);
entry:=flag*(Alert(flag=0,2)
OR entry*Cum(entry)=1);
exit:=(flag=0)*(Alert(flag,2)
OR exit*Cum(exit)=1);

EntryVal:=ValueWhen(1,entry,Ref(C,0));
Profit:=Ref(C,0)/EntryVal-1;
ProfitPer:=(flag*(-Profit)+Cum(exit*(-Profit)))*100;

Ret:=exit*Profit*100;
Ret;
johnl  
#4 Posted : Friday, March 4, 2011 7:05:55 PM(UTC)
johnl

Rank: Advanced Member

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

Plotting the pnl on the exit bar is as close as I can get.

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.