Trade Equity GV SE Files. (Updated 10 March 2007) The GV.DLL file is required for the Trade Equity indicator in this document. These indicators run on MS 7.0 and above. Date Filter Entry Binary Exit Binary Entry Price Exit Price Trade Equity GV SE {V6.2} Trade Equity SE Display {V6.2} Trade Equity SE Display Options {V6.2} These explorations run on MS 7.0 and above. Trade Equity GV SE 1 Trade Equity GV SE 2 Trade Equity GV SE 3 Trade Equity GV SE 4 These explorations run on MS 10 and above. Trade Equity GV SE V10 1/2 Trade Equity GV SE V10 3/4 These Excel macros can be used to summarize exploration results. Paste exploration reports into workbook cells 1A, 1J, 1S and 1AB. Trade_Equity_Report (MS 7.0 and above) Trade_Equity_Report_V10 (MS 10 and above) INDICATORS - Install in the listed order. -------8<---------------------------------- {Date Filter} {2004 Roy Larsen} Sd:=Input("Start day" ,1,31,1); Sm:=Input("Start month",1,12,1); Sy:=Input("Start year" ,1980,2010,2002); Ed:=Input("End day" ,1,31,31); Em:=Input("End month" ,1,12,12); Ey:=Input("End year" ,1980,2010,2008); Start:=(DayOfMonth()>=Sd AND Month()=Sm AND Year()=Sy) OR Year()>Sy OR (Year()=Sy AND Month()>Sm); End:=(DayOfMonth()<=Ed AND Month()=Em AND Year()=Ey) OR Year()Ref(L,-2) AND Ref(L,-1)>Ref(L,-2) AND Ref(L,-3)>Ref(L,-2) AND Ref(L,-4)>Ref(L,-2)),Ref(L,-2)); Cross(F2,L)*Fml("Date Filter"); -------8<---------------------------------- {Entry Price} {CLOSE} F1:=ValueWhen(1,Cum(1)=5 OR HRef(L,-2) AND Ref(L,-1)>Ref(L,-2) AND Ref(L,-3)>Ref(L,-2) AND Ref(L,-4)>Ref(L,-2),Ref(L,-2)); Cross(F2,L)*C*Fml("Date Filter"); -------8<---------------------------------- {Trade Equity GV SE} {V6.2} {2003-2007 Roy Larsen} I:=Input("Display Options 0-22",0,22,0); B:=Input("Short 1=O 2=C 3=H 4=L 5=Stop",1,5,2); Z:=Input("Cover 1=O 2=C 3=H 4=L 5=Stop",1,5,2); A:=Input("Cost Factor 0-2 (/1 /10 /100)",0,2,0); Cn:=Input("Short/Cover Costs",0,999999,0025025); Nd:=Input("Short/Cover Delays",0,55,00); Cp:=5000;{size} F:=-1;{Cp factor} N:= Fml("Exit Binary");{Sell Short} Ns:=0; X:= Fml("Entry Binary");{Buy to Cover} Xs:=0; {* code area *} I:=ExtFml("GV.SetVar","Se",I); I:=Int(11*Frac(A/10));I:=If(I>1,100,If(I=1,10,1)); Ns:=(B=5)*Ns;Cn:=(Cp>0)*Cn; F:=ValueWhen(1+Nd,1,If(F=0,-1,If(Abs(F)>1,Abs(F),-F))); Cx:=(Cn-1000*Int(Cn/1000))/I;Cn:=Int(Cn/1000)/I; Xd:=LastValue(Int(Frac(Nd/9)*10)); Nd:=LastValue(Int(Nd/9)); M:=If(Ns>0,Min(H,Max(L,Ns)),If(B=1,O,If(B=3,H,If(B=4,L,C)))); N:=N AND Alert(N=0,2)+(Cum(N>-1)=1); X:=X AND (Z<5)*(Alert(X=0,2)+(Cum(N>-1)=1)); N:=ValueWhen(1+Nd,1,N);N:=If(B<5,N,Ns>0); Y:=If(Xs>0,Min(H,Max(L,Xs)),If(Z=1,O,If(Z=3,H,If(Z=4,L,C)))); X:=ValueWhen(1+Xd,1,X);X:=X+Xs>0; Y:=If((Z<5)*(X=0),C,Y); Y:=If((Xs>0)*N*X,Xs,Y); I:=Cum(Abs(F)+N+X>-2)=1;N:=(I>-1)*N; Y:=If((N+X=0)*Alert(N*X,2),ValueWhen(2,1,Y),Y); Tr:=BarsSince(I+N)<(BarsSince(I+X)+(Cum(N)=1 AND Cum(I+X)=1)); Tr:=If(N*X*(Alert(Tr,2)+((Nd+Xd<1)* (B<>2)*(Z>1)*(Max(B,Z)>4 OR B<>Z))),1,Tr); En:=(Tr+Alert(Tr=0,2)=2)+I; Ex:=(Tr=0)*Alert(Tr,2);M:=If(I*(N=0),C,M); Lb:=Alert(Tr,2)*(LastValue(Cum(1))=Cum(1)); A:=ValueWhen(1,En,If(M=0,1,M)); F:=ValueWhen(1,En,If(F<0,Cp*Abs(F),If(F<=1,Int((F*Cp-Cn)/A)*A+Cn,F*A+Cn)))*(Cp>0); En:=Tr*(Alert(Tr=0,2)+I>0); N:=(Ex+Lb>0)*If(Cp=0,A-Y,(F-Cn)*((A-Y)/A)-Cn-Ex*Cx); B:=Alert(Tr,2)*(1+BarsSince(En+I)); Xs:=Alert(Tr,2)*If(Cp=0,A-Y,(F-Cn)*((A-Y)/A)-Cn-Ex*Cx); Nd:=LowestSince(1,I,Xs);Ns:=HighestSince(1,I,Xs); X:=Cum((Ex+Lb>0)*(N>0)*B);Xd:=Cum((Ex+Lb>0)*(N<=0)*B); M:=Cum(N)+Cp+Tr*(Lb=0)*If(Cp=0,A-Y,(F-Cn)*((A-Y)/A)-Cn); I:=ExtFml("GV.SetVar","I",I);I:=ExtFml("GV.SetVar","N",N); I:=ExtFml("GV.SetVar","X",X);I:=ExtFml("GV.SetVar","Cn",Cn); I:=ExtFml("GV.SetVar","Cp",Cp);I:=ExtFml("GV.SetVar","Cx",Cx); I:=ExtFml("GV.SetVar","En",En);I:=ExtFml("GV.SetVar","Ex",Ex); I:=ExtFml("GV.SetVar","Lb",Lb);I:=ExtFml("GV.SetVar","Nd",Nd); I:=ExtFml("GV.SetVar","Ns",Ns);I:=ExtFml("GV.SetVar","Tr",Tr); I:=ExtFml("GV.SetVar","Xd",Xd);I:=ExtFml("GV.SetVar","Xs",Xs); I:=ExtFml("GV.SetVar","F",F);I:=ExtFml("GV.SetVar","Eq",M); {Fml("Trade Equity SE Display")}M; -------8<---------------------------------- {Trade Equity SE Display Options} {V6.2} {2004-2007 Roy Larsen} {Use this document as a guide for setting} {the "F" variable and display options} {in the Trade Equity GV SE indicator} {The "F" variable allows position sizing to be set by an external formula, if desired, and with it the user can: a, apply all capital to a trade b, apply a fraction of capital to a trade c, trade a stipulated number of shares d, trade whole shares up to limit of capital e, trade whole shares with fraction of capital.} {** Position size options for "F" variable: > 1 and <-1, buy Abs(F) shares = 1, Cp*F - use all capital > 0 and < 1, Cp*F - use "F" fraction of capital < 0 and >-1, Cp*F - as above, whole shares only =-1, Cp*F - use all capital, whole shares only} {The Trade Equity SE Display indicator allows various Trade Equity statistics to be plotted directly on an open chart. To enable the Display module for Trade Equity GV SE, braces must be removed from "Trade Equity GV SE Display ("see last line of the Trade Equity GV SE indicator) and placed around M (normal output also on the last line of Trade Equity GV SE).} {** Display options: 0, $ gross profit or loss 1, $ net profit or loss - excludes capital (Cp) 2, $ equity gain or loss per trade 3, % equity gain or loss per trade 4, $ gain from winning trades 5, $ loss from losing trades 6, # of winning trades 7, # of losing trades 8, trade is currently active 9, bars in each trade 10, total bars in all trades 11, maximum favorable excursion 12, maximum adverse excursion 13, % gross profit or loss 14, maximum $ risk per trade 15, maximum % risk per trade 16, maximum $ risk across all trades 17, maximum % risk across all trades 18, cost of last position entered (F) 19, $ return at years end 20, % return at years end 21, $ return at current-date end-of-year 22, % return at current-date end-of-year} {** end of document} -------8<---------------------------------- {Trade Equity SE Display} {V6.2} {2004-2007 Roy Larsen} {Use with Trade Equity GV SE} D:=DayOfMonth();A:=LastValue(D); M:=Month();B:=LastValue(M);Y:=Year(); G:=M*31+D-(M>B OR (M=B AND D>A))*372; G:=G20,G,Y<>ValueWhen(2,1,Y)) OR Cum(I)=0 OR Cum(I)=2; Y:=TroughBars(1,Y,1)=0 OR Alert(Cum(I)=1,3) OR Cum(1)=LastValue(Cum(1)); A:=ValueWhen(1,Y,M); B:=ValueWhen(2,Y,M); G:=PREC(100*(A-B)*(B<>0)/(Abs(B)+(B=0)),2); D:=If(Z=0,M,If(Z=1,M-Cp,If(Z=2,N+M-Cp-Cum(N), If(Z=3,100*(N+M-Cp-Cum(N))/(F+(Cp=0)), If(Z=4,Cum((N>0)*N), If(Z=5,Cum((N<0)*N),If(Z=6,Cum(N>0), If(Z=7,Cum(Ex+Lb>0 AND N<=0),If(Z=8,Tr, If(Z=9,BarsSince(I OR Alert(Tr,2)=0)*Alert(Tr,2),M)))))))))); If(Z<10,D,If(Z=10,Cum(Alert(Tr,2)), If(Z=11,Ns,If(Z=12,Nd,If(Z=13,100*(M-Cp)/(F+(Cp=0)), If(Z=14,Rd,If(Z=15,Rp,If(Z=16,Rd,If(Z=17,Rp, If(Z=18,F,If(Z=19,(A-B)*(B<>0),If(Z=20,G, If(Z=21,(A-B)*(B<>0),G))))))))))))); -------8<--------------------------------------- EXPLORATIONS - Install indicators first. -------8<---------------------------------- {Trade Equity GV SE 1} {2004-2007 Roy Larsen, for MS V7.X – V10.X} {This is the first of four Trade Equity GV SE explorations for MS 7.0 and above. These explorations create trading system performance reports that can be copied to Excel spreadsheets for summary and further analysis.} {Column A: $ Profit} {Net profit} Eq:=Fml("Trade Equity GV SE"); Tr:=ExtFml("GV.GetVar","Tr"); Cp:=ExtFml("GV.GetVar","Cp"); En:=ExtFml("GV.GetVar","En"); Equity:=ExtFml("GV.GetVar","Equity"); Trades:=ExtFml("GV.GetVar","Trades"); Number:=ExtFml("GV.GetVar","Number"); Equity:=ExtFml("GV.SetVar","Equity",Eq+Equity-Cp); Trades:=ExtFml("GV.SetVar","Trades",Trades+Tr); Number:=ExtFml("GV.SetVar","Number",Number+En); N:=ExtFml("GV.GetVar","N"); LastValue(Cum(N)); {Column B: $ Win} {Amount of winning trades} N:=ExtFml("GV.GetVar","N"); LastValue(Cum((N>0)*N)); {Column C: $ Loss} {Amount of losing trades} N:=ExtFml("GV.GetVar","N"); LastValue(Cum((N<0)*N)); {Column D: # Win} {Number of winning long trades} N:=ExtFml("GV.GetVar","N"); LastValue(Cum(N>0)); {Column E: # Loss} {Number of losing long trades} Ex:=ExtFml("GV.GetVar","Ex"); Lb:=ExtFml("GV.GetVar","Lb"); N:=ExtFml("GV.GetVar","N"); LastValue(Cum((Ex OR Lb) AND N<=0)); {Column F: # BarsIn} {Total bars in all trades} Tr:=ExtFml("GV.GetVar","Tr"); LastValue(Cum(If(Alert(Tr<>0,2),1,0))); {Filter} Cum(Alert(ExtFml("GV.GetVar","Tr")<>0,2))>0; Filter enabled Yes Periodicity As required Records required XXX -------8<---------------------------------- {Trade Equity GV SE 2} {2004-2007 Roy Larsen, for MS V7.X – V10.X} {This is the second of four Trade Equity GV SE explorations for MS 7.0 and above. These explorations create trading system performance reports that can be copied to Excel spreadsheets for summary and further analysis.} Col A: #BarsOut {Bars out} Eq:=Fml("Trade Equity GV SE"); Tr:=ExtFml("GV.GetVar","Tr"); Cum(Tr>-1)-Cum(Alert(Tr,2)); Col B: #TotBars {Explored bars total} I:=ExtFml("GV.GetVar","I"); Cum(If(I>-1,1,0)); Col C: $ Costs {Commissions paid} Cn:=ExtFml("GV.GetVar","Cn"); Cx:=ExtFml("GV.GetVar","Cx"); En:=ExtFml("GV.GetVar","En"); Ex:=ExtFml("GV.GetVar","Ex"); Cum(If(En,Cn,If(Ex,Cx,0))); Col D: Buy/Hold {Buy & hold profit/loss, first bar or signal} Cn:=ExtFml("GV.GetVar","Cn"); Cp:=ExtFml("GV.GetVar","Cp"); Tr:=ExtFml("GV.GetVar","Tr"); Ea:=ValueWhen(1,Cum(1)=1 {OR Cum(Tr)=1} ,C); Ea:=LastValue(Ea); Xp:=LastValue(C); If(Cp>0,((Cp-Cn)*(Xp/Ea))-Cp,(Xp-Ea)); Col E: P Index {Profit index} N :=ExtFml("GV.GetVar","N"); Gn:=Cum(If(N>0,N,0)); Ls:=Cum(If(N<0,N,0)); Gn:=If(Gn=0,-1,Gn); If(Gn=-1,0,PREC(100*(Gn+Ls)/Gn,1)); Col F: In Trade {Currently in a trade} ExtFml("GV.GetVar","Tr"); {Filter} Cum(Alert(ExtFml("GV.GetVar","Tr")<>0,2))>0; Filter enabled: Yes Periodicity: As required Records required: User specified -------8<---------------------------------- {Trade Equity GV SE 3} {2004-2007 Roy Larsen, for MS V7.X – V10.X} {This is the third of four Trade Equity GV SE explorations for MS 7.0 and above. These explorations create trading system performance reports that can be copied to Excel spreadsheets for summary and further analysis.} Col A: $Max DD {Maximum open trade drawdown} Eq:=Fml("Trade Equity GV SE"); ExtFml("GV.GetVar","Nd"); Col B: $MaxProf {Maximum open trade profit} ExtFml("GV.GetVar","Ns"); Col C: Win Bars {Total bars in winning trades} ExtFml("GV.GetVar","X"); Col D: LoseBars {Total bars in losing trades} ExtFml("GV.GetVar","Xd"); Col E: Max Win {Maximum consecutive winning trades} Ex:=ExtFml("GV.GetVar","Ex"); Lb:=ExtFml("GV.GetVar","Lb"); N :=ExtFml("GV.GetVar","N"); I:=Cum(Ex>-1)=2; Up:=N>0; Dn:=N<=0 AND (Ex OR Lb); Ca:=If(BarsSince(I OR Up)>=BarsSince(I OR Dn),0,1); Ct:=Cum(Cross(Up,0.5))-ValueWhen(1,I OR (Ca AND Alert(Ca=0,2)) OR (Ca=0 AND Alert(Ca,2)),Cum(Cross(Up,0.5))); Cup:=If(Ca,Ct+1,Ct); HighestSince(1,I,Cup); Col F: Max Lose {Maximum consecutive losing trades} Ex:=ExtFml("GV.GetVar","Ex"); Lb:=ExtFml("GV.GetVar","Lb"); N :=ExtFml("GV.GetVar","N"); I:=Cum(Ex>-1)=2; Up:=N>0; Dn:=N<=0 AND (Ex OR Lb); Ca:=If(BarsSince(I OR Dn)>=BarsSince(I OR Up),0,1); Ct:=Cum(Cross(Dn,0.5))-ValueWhen(1,I OR (Ca AND Alert(Ca=0,2)) OR (Ca=0 AND Alert(Ca,2)),Cum(Cross(Dn,0.5))); Cdn:=If(Ca,Ct+1,Ct); HighestSince(1,I,Cdn); {Filter} Cum(Alert(ExtFml("GV.GetVar","Tr")<>0,2))>0; Filter enabled: Yes Periodicity: As required Records required: User specified -------8<---------------------------------- {Trade Equity GV SE 4} {2004-2007 Roy Larsen, for MS V7.X – V10.X} {This is the last of four Trade Equity GV SE explorations for MS 7.0 and above. These explorations create trading system performance reports that can be copied to Excel spreadsheets for summary and further analysis.} Col A: B/H DwDn {Maximum buy and hold drawdown} Eq:=Fml("Trade Equity GV SE"); Cn:=ExtFml("GV.GetVar","Cn"); Cp:=ExtFml("GV.GetVar","Cp"); Tr:=ExtFml("GV.GetVar","Tr"); Ea:=ValueWhen(1,Cum(1)=1 {OR Cum(Tr)=1} ,C); I :=Cum(Ea>0)=1; Ea:=LastValue(Ea); Gl:=If(Cp>0,((Cp-Cn)*(C/Ea))-Cp,(C-Ea)); LowestSince(1,I,Gl); Col B: B/H +Exc {Maximum buy and hold positive excursion} Cn:=ExtFml("GV.GetVar","Cn"); Cp:=ExtFml("GV.GetVar","Cp"); Tr:=ExtFml("GV.GetVar","Tr"); Ea:=ValueWhen(1,Cum(1)=1 {OR Cum(Tr)=1} ,C); I :=Cum(Ea>0)=1; Ea:=LastValue(Ea); Gl:=If(Cp>0,((Cp-Cn)*(C/Ea))-Cp,(C-Ea)); HighestSince(1,I,Gl); Col C: AvgeWin {Average win} N :=ExtFml("GV.GetVar","N"); Gn:=Cum(If(N>0,N,0)); Up:=Cum(If(N>0,1,0)); Up:=If(Up=0,-1,Up); Gn:=If(Up=0,1,Gn); If(Gn/Up=-1,0,Gn/Up); Col D: AvgeLoss {Average loss} Ex:=ExtFml("GV.GetVar","Ex"); Lb:=ExtFml("GV.GetVar","Lb"); N :=ExtFml("GV.GetVar","N"); Ls:=Cum(If(N<0,N,0)); Dn:=Cum(If(N<=0 AND (Ex OR Lb),1,0)); Dn:=If(Dn=0,-1,Dn); Ls:=If(Dn=0,-1,Ls); If(Ls/Dn>0,0,Ls/Dn); Col E: GL Ratio {Average gain/loss ratio} Ex:=ExtFml("GV.GetVar","Ex"); Lb:=ExtFml("GV.GetVar","Lb"); N :=ExtFml("GV.GetVar","N"); Gn:=Cum(If(N>0,N,0)); Up:=Cum(If(N>0,1,0)); Ls:=Cum(If(N<0,N,0)); Ok:=Gn>0 AND Ls<0; Dn:=Cum(If(N<=0 AND (Ex OR Lb),1,0)); Gn:=If(Ok,Gn,-1); Ls:=If(Ok,Ls,1); Up:=If(Ok,Up,1); Dn:=If(Ok,Dn,1); Op:=(Gn/Up)/Abs(Ls/Dn); If(Op<0,0,PREC(Op,2)); Col F: PkTrough {Maximum $ peak-to-trough range} I :=ExtFml("GV.GetVar","I"); Tr:=ExtFml("GV.GetVar","Tr"); Xs:=ExtFml("GV.GetVar","Xs"); A :=If(Tr,HighestSince(1,Tr=0,Xs),0); B :=If(Tr,LowestSince(1,Tr=0,Xs),0); HighestSince(1,I,If(Tr,A-B,0)); {Filter} Cum(Alert(ExtFml("GV.GetVar","Tr")<>0,2))>0; Filter enabled: Yes Periodicity: As required Records required: User specified -------8<---------------------------------- {Trade Equity GV SE V10 1/2} {2003-2007 Roy Larsen} {This is the first of two Trade Equity GV SE explorations for MS 10. These explorations create trading system performance reports that can be copied to Excel spreadsheets for summary and further analysis (see the Excel macro named Trade_Equity_Report_2).} {Column A: $ Profit} {Net profit} Eq:=Fml("Trade Equity GV SE"); Tr:=ExtFml("GV.GetVar","Tr"); Cp:=ExtFml("GV.GetVar","Cp"); En:=ExtFml("GV.GetVar","En"); Equity:=ExtFml("GV.GetVar","Equity"); Trades:=ExtFml("GV.GetVar","Trades"); Number:=ExtFml("GV.GetVar","Number"); Equity:=ExtFml("GV.SetVar","Equity",Eq+Equity-Cp); Trades:=ExtFml("GV.SetVar","Trades",Trades+Tr); Number:=ExtFml("GV.SetVar","Number",Number+En); N:=ExtFml("GV.GetVar","N"); LastValue(Cum(N)); {Column B: $ Win} {Amount of winning trades} N:=ExtFml("GV.GetVar","N"); LastValue(Cum((N>0)*N)); {Column C: $ Loss} {Amount of losing trades} N:=ExtFml("GV.GetVar","N"); LastValue(Cum((N<0)*N)); {Column D: # Win} {Number of winning long trades} N:=ExtFml("GV.GetVar","N"); LastValue(Cum(N>0)); {Column E: # Loss} {Number of losing long trades} Ex:=ExtFml("GV.GetVar","Ex"); Lb:=ExtFml("GV.GetVar","Lb"); N :=ExtFml("GV.GetVar","N"); LastValue(Cum((Ex OR Lb) AND N<=0)); {Column F: # BarsIn} {Total bars in all trades} Tr:=ExtFml("GV.GetVar","Tr"); LastValue(Cum(Alert(Tr<>0,2))); {Column G: #BarsOut} {Bars out} Tr:=ExtFml("GV.GetVar","Tr"); Cum(Tr>-1)-Cum(Alert(Tr,2)); {Column H: #TotBars} {Explored bars total} I:=ExtFml("GV.GetVar","I"); Cum(I>-1); {Column I: $ Costs} {Commissions paid} Cn:=ExtFml("GV.GetVar","Cn"); Cx:=ExtFml("GV.GetVar","Cx"); En:=ExtFml("GV.GetVar","En"); Ex:=ExtFml("GV.GetVar","Ex"); Cum(En*Cn+Ex*Cx); {Column J: Buy/Hold} {Buy & hold profit/loss, first bar or signal} Cn:=ExtFml("GV.GetVar","Cn"); Cp:=ExtFml("GV.GetVar","Cp"); Tr:=ExtFml("GV.GetVar","Tr"); Ea:=ValueWhen(1,Cum(1)=1 {OR Cum(Tr)=1} ,C); Ea:=LastValue(Ea); Xp:=LastValue(C); If(Cp>0,((Cp-Cn)*(Xp/Ea))-Cp,(Xp-Ea)); {Column K: P Index} {Profit index} N :=ExtFml("GV.GetVar","N"); Gn:=Cum(If(N>0,N,0)); Ls:=Cum(If(N<0,N,0)); Gn:=If(Gn=0,-1,Gn); If(Gn=-1,0,PREC(100*(Gn+Ls)/Gn,1)); {Column L: In Trade} {Currently in a trade} ExtFml("GV.GetVar","Tr"); {Filter} Cum(Alert(ExtFml("GV.GetVar","Tr")<>0,2))>0; Filter enabled: Yes Periodicity: As required Records required: User specified -------8<---------------------------------- {Trade Equity GV SE V10 3/4} {2003-2007 Roy Larsen} {This is the second of two Trade Equity GV SE explorations for MS 10. These explorations create trading system performance reports that can be copied to Excel spreadsheets for summary and further analysis (see the Excel macro named Trade_Equity_Report_2).} {Column A: $ MAE} {Maximum adverse excursion - $ or %} Eq:=Fml("Trade Equity GV SE"); Nd:=ExtFml("GV.GetVar","Nd"); Nd; {Cp:=ExtFml("GV.GetVar","Cp"); Ndp:=PREC(100*Nd/Cp,1); Ndp;} {Column B: $ MFE} {Maximum favourable excursion - $ or %} Ns:=ExtFml("GV.GetVar","Ns"); Ns; {Cp:=ExtFml("GV.GetVar","Cp"); Nsp:=PREC(100*Ns/Cp,1); Nsp;} {Column C: Win Bars} {Total bars in winning trades} ExtFml("GV.GetVar","X"); {Column D: LoseBars} {Total bars in losing trades} ExtFml("GV.GetVar","Xd"); {Column E: Max Win} {Maximum consecutive winning trades} Ex:=ExtFml("GV.GetVar","Ex"); Lb:=ExtFml("GV.GetVar","Lb"); N :=ExtFml("GV.GetVar","N"); I:=Cum(Ex>-1)=2; Up:=N>0; Dn:=N<=0 AND (Ex OR Lb); Ca:=If(BarsSince(I OR Up)>=BarsSince(I OR Dn),0,1); Ct:=Cum(Cross(Up,0.5))-ValueWhen(1,I OR (Ca AND Alert(Ca=0,2)) OR (Ca=0 AND Alert(Ca,2)),Cum(Cross(Up,0.5))); Cup:=If(Ca,Ct+1,Ct); HighestSince(1,I,Cup); {Column F: Max Lose} {Maximum consecutive losing trades} Ex:=ExtFml("GV.GetVar","Ex"); Lb:=ExtFml("GV.GetVar","Lb"); N :=ExtFml("GV.GetVar","N"); I:=Cum(Ex>-1)=2; Up:=N>0; Dn:=N<=0 AND (Ex OR Lb); Ca:=If(BarsSince(I OR Dn)>=BarsSince(I OR Up),0,1); Ct:=Cum(Cross(Dn,0.5))-ValueWhen(1,I OR (Ca AND Alert(Ca=0,2)) OR (Ca=0 AND Alert(Ca,2)),Cum(Cross(Dn,0.5))); Cdn:=If(Ca,Ct+1,Ct); HighestSince(1,I,Cdn); {Column G: B/H DwDn} {Maximum buy and hold adverse excursion} Cn:=ExtFml("GV.GetVar","Cn"); Cp:=ExtFml("GV.GetVar","Cp"); Tr:=ExtFml("GV.GetVar","Tr"); Ea:=ValueWhen(1,Cum(1)=1 {OR Cum(Tr)=1} ,C); I :=Cum(Ea>0)=1; Ea:=LastValue(Ea); Gl:=If(Cp>0,((Cp-Cn)*(C/Ea))-Cp,(C-Ea)); LowestSince(1,I,Gl); {Column H: B/H +Exc} {Maximum buy and hold favourable excursion} Cn:=ExtFml("GV.GetVar","Cn"); Cp:=ExtFml("GV.GetVar","Cp"); Tr:=ExtFml("GV.GetVar","Tr"); Ea:=ValueWhen(1,Cum(1)=1 {OR Cum(Tr)=1} ,C); I :=Cum(Ea>0)=1; Ea:=LastValue(Ea); Gl:=If(Cp>0,((Cp-Cn)*(C/Ea))-Cp,(C-Ea)); HighestSince(1,I,Gl); {Column I: AvgeWin} {Average win} N :=ExtFml("GV.GetVar","N"); Gn:=Cum((N>0)*N); Up:=Cum(N>0); Up:=If(Up=0,-1,Up); Gn:=If(Up=0,1,Gn); If(Gn/Up=-1,0,Gn/Up); {Column J: AvgeLoss} {Average loss} Ex:=ExtFml("GV.GetVar","Ex"); Lb:=ExtFml("GV.GetVar","Lb"); N :=ExtFml("GV.GetVar","N"); Ls:=Cum((N<0)*N); Dn:=Cum(N<=0 AND (Ex OR Lb)); Dn:=If(Dn=0,-1,Dn); Ls:=If(Dn=0,-1,Ls); If(Ls/Dn>0,0,Ls/Dn); {Column K: GL Ratio} {Average gain/loss ratio} Ex:=ExtFml("GV.GetVar","Ex"); Lb:=ExtFml("GV.GetVar","Lb"); N :=ExtFml("GV.GetVar","N"); Gn:=Cum((N>0)*N); Up:=Cum(N>0); Ls:=Cum((N<0)*N); Ok:=Gn>0 AND Ls<0; Dn:=Cum(N<=0 AND (Ex OR Lb)); Gn:=If(Ok,Gn,-1); Ls:=If(Ok,Ls,1); Up:=If(Ok,Up,1); Dn:=If(Ok,Dn,1); Op:=(Gn/Up)/Abs(Ls/Dn); If(Op<0,0,PREC(Op,2)); {Column L: PkTrough} {Maximum $ peak-to-trough range} I :=ExtFml("GV.GetVar","I"); Tr:=ExtFml("GV.GetVar","Tr"); Xs:=ExtFml("GV.GetVar","Xs"); A :=If(Tr,HighestSince(1,Tr=0,Xs),0); B :=If(Tr,LowestSince(1,Tr=0,Xs),0); HighestSince(1,I,If(Tr,A-B,0)); {Filter} Cum(Alert(ExtFml("GV.GetVar","Tr")<>0,2))>0; Filter enabled: Yes Periodicity: As required Records required: User specified -------8<---------------------------------- EXCEL MACROS -------8<---------------------------------- Sub Trade_Equity_Report() ' ' Trade Equity GV LE/SE/DE macro for MS 6-column exploration reports ' Macro recorded 12/12/2006 by Roy Larsen ' Columns("A:A").Select Selection.ColumnWidth = 25 Columns("B:B").Select Selection.ColumnWidth = 12 Columns("H:J").Select Selection.Delete Shift:=xlToLeft ActiveWindow.LargeScroll ToRight:=1 Columns("N:P").Select Selection.Delete Shift:=xlToLeft Columns("T:V").Select Selection.Delete Shift:=xlToLeft Columns("AA:AA").Select Selection.Delete Shift:=xlToLeft Columns("B:Y").Select SelectionNumberFormat = "0_ ;[Red]-0 " Columns("B:D").Select Selection.NumberFormat = "0.00_ ;[Red]-0.00 " ActiveWindow.LargeScroll ToRight:=0 Rows("1:1").Select Selection.Font.Bold = True Selection.Copy Application.Goto Reference:="R1000C1" ActiveSheet.Paste Application.CutCopyMode = False Range("A1000").Select ActiveCell.FormulaR1C1 = "Portfolio Performance" Range("A1001").Select ActiveCell.FormulaR1C1 = "Net $ Profit" Range("A1002").Select ActiveCell.FormulaR1C1 = "$ Won" Range("A1003 ").Select ActiveCell.FormulaR1C1 = "$ Lost" Range("A1004").Select ActiveCell.FormulaR1C1 = "# Wins" Range("A1005").Select ActiveCell.FormulaR1C1 = "# Losses" Range("A1006").Select ActiveCell.FormulaR1C1 = "Average Win/Loss Ratio" Range("A1007").Select ActiveCell.FormulaR1C1 = "Profit Factor" Range("A1008").Select ActiveCell.FormulaR1C1 = "Profit Index" Range("A1009").Select ActiveCell.FormulaR1C1 = "%Profitable" Range("A1010").Select ActiveCell.FormulaR1C1 = "Average Win" Range("A1011").Select ActiveCell.FormulaR1C1 = "Average Loss" Range("A1012").Select ActiveCell.FormulaR1C1 = "Average Trade" Range("A1013").Select ActiveCell.FormulaR1C1 = "Pessimistic Return" Range("A1014").Select ActiveCell.FormulaR1C1 = "% Time Invested" Range("A1015").Select ActiveCell.FormulaR1C1 = "Max Adverse Excursion" Range("A1016").Select ActiveCell.FormulaR1C1 = "Max Favorable Excursion" Range("B1000").Select Selection.ClearContents Range("B1001").Select ActiveCell.FormulaR1C1 = "=SUM(R[-999]C:R[-2]C)" Range("B1001").Select Selection.Font.Bold = True ActiveWindow.LargeScroll ToRight:=1 Range("B1001:Y1001").Select Selection.FillRight Range("B1001").Select ActiveWindow.LargeScroll ToRight:=1 Range("B1001:Y1001").Select Selection.NumberFormat = "0_ ;[Red]-0 " Range("B1002").Select ActiveCell.FormulaR1C1 = "=R[-1]C[1]" Range("B1003").Select ActiveCell.FormulaR1C1 = "=R[-2]C[2]" Range("B1004").Select ActiveCell.FormulaR1C1 = "=R[-3]C[3]" Range("B1005").Select ActiveCell.FormulaR1C1 = "=R[-4]C[4]" Range("B1006").Select ActiveCell.FormulaR1C1 = "=(R[-5]C[1]/R[-5]C[3])/ABS(R[-5]C[2]/R[-5]C[4])" Range("B1007").Select ActiveCell.FormulaR1C1 = "=ABS(R[-6]C[1]/R[-6]C[2])" Range("B1008").Select ActiveCell.FormulaR1C1 = "=100*(R[-7]C[1]+R[-7]C[2])/R[-7]C[1]" Range("B1009").Select ActiveCell.FormulaR1C1 = "=100*R[-8]C[3]/(R[-8]C[3]+R[-8]C[4])" Range("B1010").Select ActiveCell.FormulaR1C1 = "=R[-9]C[1]/R[-9]C[3]" Range("B1011").Select ActiveCell.FormulaR1C1 = "=R[-10]C[2]/R[-10]C[4]" Range("B1012").Select ActiveCell.FormulaR1C1 = "=(R[-11]C[1]+R[-11]C[2])/(R[-11]C[3]+R[-11]C[4])" Range("B1013").Select ActiveCell.FormulaR1C1 = "=((R[-12]C[3]-SQRT(R[-12]C[3]))*(R[-12]C[1]/R[-12]C[3]))/((R[-12]C[4]-SQRT(R[-12]C[4]))*ABS(R[-12]C[2]/R[-12]C[4]))" Range("B1013").Select Selection.NumberFormat = "0.00" Range("B1014").Select ActiveCell.FormulaR1C1 = "=100*(R[-13]C[5]/R[-13]C[7])" Range("B1015").Select ActiveCell.FormulaR1C1 = "=MINA(R[-1013]C[12]:R[-16]C[12])" Range("B1016").Select ActiveCell.FormulaR1C1 = "=MAXA(R[-1014]C[13]:R[-17]C[13])" Range("B1004:B1005").Select Selection.NumberFormat = "0_ ;[Red]-0 " Range("B1001:B1003 ").Select Selection.NumberFormat = "$#,##0_);[Red]($#,##0)" Range("B1010:B1012").Select Selection.NumberFormat = "$#,##0_);[Red]($#,##0)" Range("B1015:B1016").Select Selection.NumberFormat = "$#,##0_);[Red]($#,##0)" Range("B1001:B1016").Select Selection.Font.Bold = True Range("A1000").Select ActiveWindow.SmallScroll Down:=16 End Sub -------8<---------------------------------- Sub Trade_Equity_Report_V10() ' ' Trade Equity GV LE/SE/DE macro for MS 12-column exploration reports ' Excel macro recorded 12/12/2006 by Roy Larsen ' Columns("A:A").Select Selection.ColumnWidth = 25 Columns("B:B").Select Selection.ColumnWidth = 12 ActiveWindow.LargeScroll ToRight:=1 Columns("N:P").Select Selection.Delete Shift:=xlToLeft Columns("AA:AA").Select Selection.Delete Shift:=xlToLeft Columns("B:Y").Select SelectionNumberFormat = "0_ ;[Red]-0 " Columns("B:D").Select Selection.NumberFormat = "0.00_ ;[Red]-0.00 " ActiveWindow.LargeScroll ToRight:=0 Rows("1:1").Select Selection.Font.Bold = True Selection.Copy Application.Goto Reference:="R1000C1" ActiveSheet.Paste Application.CutCopyMode = False Range("A1000").Select ActiveCell.FormulaR1C1 = "Portfolio Performance" Range("A1001").Select ActiveCell.FormulaR1C1 = "Net $ Profit" Range("A1002").Select ActiveCell.FormulaR1C1 = "$ Won" Range("A1003 ").Select ActiveCell.FormulaR1C1 = "$ Lost" Range("A1004").Select ActiveCell.FormulaR1C1 = "# Wins" Range("A1005").Select ActiveCell.FormulaR1C1 = "# Losses" Range("A1006").Select ActiveCell.FormulaR1C1 = "Average Win/Loss Ratio" Range("A1007").Select ActiveCell.FormulaR1C1 = "Profit Factor" Range("A1008").Select ActiveCell.FormulaR1C1 = "Profit Index" Range("A1009").Select ActiveCell.FormulaR1C1 = "%Profitable" Range("A1010").Select ActiveCell.FormulaR1C1 = "Average Win" Range("A1011").Select ActiveCell.FormulaR1C1 = "Average Loss" Range("A1012").Select ActiveCell.FormulaR1C1 = "Average Trade" Range("A1013").Select ActiveCell.FormulaR1C1 = "Pessimistic Return" Range("A1014").Select ActiveCell.FormulaR1C1 = "% Time Invested" Range("A1015").Select ActiveCell.FormulaR1C1 = "Max Adverse Excursion" Range("A1016").Select ActiveCell.FormulaR1C1 = "Max Favorable Excursion" Range("B1000").Select Selection.ClearContents Range("B1001").Select ActiveCell.FormulaR1C1 = "=SUM(R[-999]C:R[-2]C)" Range("B1001").Select Selection.Font.Bold = True ActiveWindow.LargeScroll ToRight:=1 Range("B1001:Y1001").Select Selection.FillRight Range("B1001").Select ActiveWindow.LargeScroll ToRight:=1 Range("B1001:Y1001").Select Selection.NumberFormat = "0_ ;[Red]-0 " Range("B1002").Select ActiveCell.FormulaR1C1 = "=R[-1]C[1]" Range("B1003").Select ActiveCell.FormulaR1C1 = "=R[-2]C[2]" Range("B1004").Select ActiveCell.FormulaR1C1 = "=R[-3]C[3]" Range("B1005").Select ActiveCell.FormulaR1C1 = "=R[-4]C[4]" Range("B1006").Select ActiveCell.FormulaR1C1 = "=(R[-5]C[1]/R[-5]C[3])/ABS(R[-5]C[2]/R[-5]C[4])" Range("B1007").Select ActiveCell.FormulaR1C1 = "=ABS(R[-6]C[1]/R[-6]C[2])" Range("B1008").Select ActiveCell.FormulaR1C1 = "=100*(R[-7]C[1]+R[-7]C[2])/R[-7]C[1]" Range("B1009").Select ActiveCell.FormulaR1C1 = "=100*R[-8]C[3]/(R[-8]C[3]+R[-8]C[4])" Range("B1010").Select ActiveCell.FormulaR1C1 = "=R[-9]C[1]/R[-9]C[3]" Range("B1011").Select ActiveCell.FormulaR1C1 = "=R[-10]C[2]/R[-10]C[4]" Range("B1012").Select ActiveCell.FormulaR1C1 = "=(R[-11]C[1]+R[-11]C[2])/(R[-11]C[3]+R[-11]C[4])" Range("B1013").Select ActiveCell.FormulaR1C1 = "=((R[-12]C[3]-SQRT(R[-12]C[3]))*(R[-12]C[1]/R[-12]C[3]))/((R[-12]C[4]-SQRT(R[-12]C[4]))*ABS(R[-12]C[2]/R[-12]C[4]))" Range("B1013").Select Selection.NumberFormat = "0.00" Range("B1014").Select ActiveCell.FormulaR1C1 = "=100*(R[-13]C[5]/R[-13]C[7])" Range("B1015").Select ActiveCell.FormulaR1C1 = "=MINA(R[-1013]C[12]:R[-16]C[12])" Range("B1016").Select ActiveCell.FormulaR1C1 = "=MAXA(R[-1014]C[13]:R[-17]C[13])" Range("B1004:B1005").Select Selection.NumberFormat = "0_ ;[Red]-0 " Range("B1001:B1003 ").Select Selection.NumberFormat = "$#,##0_);[Red]($#,##0)" Range("B1010:B1012").Select Selection.NumberFormat = "$#,##0_);[Red]($#,##0)" Range("B1015:B1016").Select Selection.NumberFormat = "$#,##0_);[Red]($#,##0)" Range("B1001:B1016").Select Selection.Font.Bold = True Range("A1000").Select ActiveWindow.SmallScroll Down:=16 End Sub -------8<----------------------------------