Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/27/2006(UTC) Posts: 135
|
Below is the profit curve code from jose
Try implementing a specific of bars exit on the code but the the plot didn't exit on the specific number of bars exit. Anyone know whats wrong with the code? The one in bold are altered code
{* Entry Long formula/reference *} { SMA crossover entry - do not trade! } entry:=Cross(Mov(C,5,S),Mov(C,10,S));
{* Exit Long formula/reference *} { Reverse SMA crossover exit } exit:=(Cross(C,Mov(C,10,S) AND Alert(entry,1)=0) Or (Barssince(entry)=16 and Alert(entry,1)=0);
{ User inputs } plot:=Input("[1]%Profit curve, [2]MaxDD%, [3]Trade signals",1,3,1); cost:=Input("Total Transaction costs (Brokerage + Slippage) %:",0,100,.2)/200;
{ Trade Binary & clean Entry/Exit signals } 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);
{ Profit Long % curve } EntryVal:=ValueWhen(1,entry,C*(1+cost)); Profit:=C*(1-cost)/EntryVal-1; ProfitPer:=(flag*Profit+Cum(exit*Profit))*100;
{ Profit Long % max drawdown } MaxDD:= Highest(Max(Highest(ProfitPer),0)-ProfitPer);
{ Plot in own window below chart } If(plot=1,ProfitPer,If(plot=2,MaxDD,entry-exit))
|