How to add "full name" in backtest?

Hi

I would like to add the column "Full Name" to my backtest result list, as the current selection of columns not include this field.

I have found some suggestions online (but those suggestions are for way more complicated backtest modifications) But I have modified the code to the following;

SetCustomBacktestProc("");
if( Status("action") == actionPortfolio )
{
    bo = GetBacktesterObject();
    bo.Backtest(1);
   for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
   {
       trade.AddCustomMetric("Namn", FullName()  );
   }
bo.ListTrades();
}

But it will only show the header " Namn", but no actual result in the list of trades.. Any suggestions?

BR / O

Please study CBT manual

There is FullName property of trade object

string FullName>
full name of the instrument (added in 5.69)

trade.AddCustomMetric("Full Name", trade.FullName  );

14

In order to place it as second column add

SetOption("ExtraColumnsLocation", 1);

at the top of your afl.

2 Likes

Hi

Thanks, works perfect with that change.

BR / O

And for anyone else, the working code is as follow;

SetOption("ExtraColumnsLocation", 1);
SetCustomBacktestProc("");
if( Status("action") == actionPortfolio )
{
    bo = GetBacktesterObject();
    bo.Backtest(1);
   for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
   {
       trade.AddCustomMetric("Full Name", trade.FullName  );
   }
   
       for ( trade = bo.GetFirstOpenPos( ); trade; trade = bo.GetNextOpenPos( ) )
    {
              trade.AddCustomMetric("Full Name", trade.FullName  );
    }
    
bo.ListTrades();
}
1 Like

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