Export including date-range for optimization results&walk-forward steps

Hello Everyone,
I am running a) an Optimization and b) a Walk-forward analysis for a portfolio and I want to export a file for external postprocessing.
For a) the data I need are those contained in the result-list of a standalone Optimization. For this example, I know how to export the result-list to csv, also possible in a batch.
For my purpose, one element of data is missing: the date-range, that is in the setting of the optimization.

If I now regard b) Walk-Forward, the missing data would be for each run the Start, End and Mode.
modeStartEnd

After having run the analysis, I do not see a method to systematically export the result of each individual optimization run, plus the before mentioned data. I would be grateful for a solution "out of the box", how to export the single optimization steps of a walk forward, enriched with the range-data.

As an alternative, I am also capable of programming, and I have written a piece of code that basically exports the optimization results both for individual optimizations and walk forward. But still missing are the before mentioned data. I was not able to find access to parameter settings for the Range or the Mode/Start/End either in the documentation or in the forum. Could anyone please provide these to me?

SetCustomBacktestProc("");  
if( Status("action") == actionPortfolio ) { 
    bo = GetBacktesterObject();  
    bo.Backtest(); 
    stats = bo.GetPerformanceStats( 1 ); 
    NetProfitPercent = stats.GetValue( "NetProfitPercent" );
    NetProfit = stats.GetValue( "NetProfit" );
    CAR = stats.GetValue( "CAR" );
    CAR_MDD = stats.GetValue( "CAR/MDD" );
    MaxTradeDrawdown = stats.GetValue( "MaxTradeDrawdown" );
	MaxTradeDrawdownPercent = stats.GetValue( "MaxTradeDrawdownPercent" );
	MaxSystemDrawdown = stats.GetValue( "MaxSystemDrawdown" );
	MaxSystemDrawdownPercent = stats.GetValue( "MaxSystemDrawdownPercent" );
    
	fh = fopen( "backtest.txt", "a");
	if( fh ) { 		
		fs = StrFormat("%.4f,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f\n", 
						scoreLookBack, entryLookBack, NetProfitPercent, NetProfit, CAR, CAR_MDD, 
						MaxTradeDrawdown, MaxTradeDrawdownPercent, 
						MaxSystemDrawdown, MaxSystemDrawdownPercent); 
      	_TRACE(fs);
      	fputs( fs, fh ); 
      	
      	fclose( fh );
      	}

Many thanks!
Andreas

3 Likes

good job

just add Right Bracket } at the end if your code
no more error in your code

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.