[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: EasyLanguage code to output key values in the TS Strategy Performance Report



PureBytes Links

Trading Reference Links

Peter,

	This is some old code I used to use but it basically does what
you want. To change the location of the output file just change the
variable filevar below. The directory must exist for the file to be
created. The ending(".xls") creates an excel file which you can change
as well. I think there is a measurement of the percentage drawdown based
on an initial account of $1,000,000 which I later found to be too
misleading and you should probably ignore.  There is a line that says: 

	if str="W " or str="SP" then FileAppend(filevar+ending,newline+"
sum of dis b/w MA and closes>0 then buy. Period="+numtostr(periodst,0)+
	newline+space+"Nprof"+space+"PerProf"+space+"T#"+space+"$ per
Trade"+space+"MaxDD"+space+"MaxDD%"+newline);

I used this line to create commentary of the first line of the excel
file. You must change the value of the condition if str="W" if that
commodity is not included. The way the code is set it will also work for
intraday data. If you apply this code to a bunch of charts, you can then
change your code, write commentaries, verify, and just examine the
outputted results. That is what I do, it is very efficient and the only
way I have found to analyze portfolios. Good luck.

Gabriel





Vars:trade#(0),T#(""),netprofitvar(0),inputvar(""),avgtrade(0),initaccou
nt(1000000),equityhigh(0),maxdd(0),maxddper(0),condition98(true),
	  condition99(true),condition11(true),macro(0),
		filevar("C:\3D\Serial Correlation\test"),
		PerDis(""),rrratio(""),Btime(""),Nprof(""),Perprof(""),
		ending(".xls"),space("	"),str(""),mp(0);


if initaccount+netprofit+openpositionprofit>equityhigh then
equityhigh=initaccount+netprofit+openpositionprofit;
if equityhigh<>0 and
equityhigh-(initaccount+netprofit+openpositionprofit)>maxdd then
maxdd=equityhigh-(initaccount+netprofit+openpositionprofit);
if equityhigh<>0 and
(equityhigh-(initaccount+netprofit+openpositionprofit))/equityhigh>maxdd
per then
maxddper=(equityhigh-(initaccount+netprofit+openpositionprofit))/equityh
igh;


if date=lastcalcdate-2 then begin
	if condition99 then begin
	exitlong next bar at open;
	exitshort next bar at open; 
	condition99=false;
	end;
end;
{*********OUTPUT************}


	if date=lastcalcdate-1 then begin
		if condition98 then begin
		Str=LeftStr(GetSymbolName,2);
		{PerDis=Numtostr(Pdis,3);
		RRratio=Numtostr(ratio,3);
		Btime=numtostr(barexit,1);}
		Nprof=Numtostr( netprofit,2);
{		Inputvar=Numtostr(trailbarsvar,2);}
		PerProf=Numtostr(percentprofit,3);	
		if trade#<>0 then avgtrade=Netprofit/(trade#);
		T#=numtostr(trade#,2);
{		if str="HO" or str="HG" then
FileAppend(filevar+ending,newline+"if lowest(low,"+numtostr(periodst,0)+
			")> c from "+numtostr(periodvar,0)+" bars ago
then buy." 
	
+newline+space+"Nprof"+space+"PerProf"+space+"T#"+space+"$ per
Trade"+space+"MaxDD"+space+"MaxDD%"+newline);
}		if str="W " or str="SP" then
FileAppend(filevar+ending,newline+" sum of dis b/w MA and closes>0 then
buy. Period="+numtostr(periodst,0)+
			"Square of distance from hilo as trigger. No
exits." 
	
+newline+space+"Nprof"+space+"PerProf"+space+"T#"+space+"$ per
Trade"+space+"MaxDD"+space+"MaxDD%"+newline);

		if netprofit<>0 then
FileAppend(filevar+ending,str+space+{Perdis+space+RRratio+space+Btime+sp
ace+}Nprof+space+PerProf+space+T#+space+numtostr(avgtrade,3)+space+numto
str(maxdd,2)+space+numtostr(maxddper,3)+newline) else	
	
FileAppend(filevar+ending,str+space+{Perdis+space+RRratio+space+Btime+sp
ace+}Nprof+space+PerProf+space+T#+space+numtostr(avgtrade,3)+
space+numtostr(maxiddrawdown,2)+space+"No net prof"+newline) ;
		condition98=false;
		end;
	end;

mp=marketposition;
if mp=1 and mp[1]=0 then trade#=trade#+1;
if mp=-1 and mp[1]=0 then trade#=trade#+1;
if mp=1 and mp[1]=-1 then trade#=trade#+1;
if mp=-1 and mp[1]=1 then trade#=trade#+1;





-----Original Message-----
From: Peter McKenna [mailto:pmckenn@xxxxxxxxxxxxx] 
Sent: Monday, January 12, 2004 4:45 PM
To: omega-list@xxxxxxxxxx
Subject: EasyLanguage code to output key values in the TS Strategy
Performance Report


Does anyone have EasyLanguage code that would output some of the key
values in the TS Strategy Performance Report to a file (ideally comma
delimited for excel)?

The fields I'm looking for include Total Profit/Loss, Number of Trades,
Number of Winning Trades, Number of Losing Trades, % Profitable,
Profit/Loss per Trade.

OK, this isn't rocket science, but its a good days work (at least for
me) just getting things right.

I deleted my version when I upgraded to TS 7.2 and lost the most recent
version of TSPRO.ELD.  How did this happen?  Well, I accidently
installed TS 7.2 under F:\Program.  That's right, NOT under
F:\Program\TradeStation 7.2.  So when I performed a windows uninstall of
TS 7.2, windows uninstall deleted all applications under F:\Program!
That's pretty stupid, but that's what happened!  I have a backup that's
doesn't include the required EL code.

Thanks, Peter