Hi,
I wish to export my backtest Result list to a csv file using AFL.
I have created a function that creates a Batch file with the Export action:
procedure ExportResultsUsingBatch(outputFile){
template =
"<?xml version=~1.0~ encoding=~ISO-8859-1~?>\n" +
"<AmiBroker-Batch CompactMode=~0~>\n" +
"<Step>\n" +
"<Action>Export</Action>\n" +
"<Param>" + outputFile + "</Param>\n" +
"<Param2/>\n" +
"</Step>\n" +
"</AmiBroker-Batch>\n";
xmlContent = StrReplace( template, "~", Chr( 34 ) );
fh = fopen( "C:/Program Files/AmiBroker/Formulas/Custom/FileExportBatchFile.abb", "w" );
if( fh )
{
fputs( xmlContent, fh );
fclose( fh );
}
else
{
Error("Could not open file for writing" );
}
ShellExecute("runbatch", "C:/Program Files/AmiBroker/Formulas/Custom/FileExportBatchFile.abb", "" );
}
I then run the function in the second part of the backtest:
if( Status("action") == actionPortfolio )
{
... OTHER CODE ...
ExportResultsUsingBatch("C:/Program Files/AmiBroker/Formulas/Custom/" + "results" + ".csv");
}
My batch file is created correctly and my result list is exported. However, the result list is empty:
I wonder what I might be missing here. Is there perhaps another way to achieve this?
Best regards, Comex
