oppz
November 9, 2020, 8:58am
#1
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
fxshrat
November 9, 2020, 9:12am
#2
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 );
In order to place it as second column add
SetOption("ExtraColumnsLocation", 1);
at the top of your afl.
2 Likes
oppz
November 10, 2020, 7:00am
#3
Hi
Thanks, works perfect with that change.
BR / O
oppz
November 10, 2020, 8:48am
#4
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
system
Closed
February 18, 2021, 8:48am
#5
This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.