No.
There is NO BUG. Don’t blame tools for sole purpose that you don’t know how to use them.
I copy pasted your code into AFL editor, applied Code Prettify and copy pasted it back here
and everything is indented.
BTW: don’t you have better things to do than picking would be ‘bugs’ in open source software Discourse ? Even if there was a bug I would not be able to fix it because: a) I did not write that software, b) I don’t have time
if( Status( "action" ) == actionPortfolio )
{
bo = GetBacktesterObject();
// Run default backtest procedure without generating the trade list
// Initialize accumulation variables
sumATRPnL = countATRPnL = 0;
sumATRPnLWin = countATRPnLWin = 0;
sumATRPnLLoss = countATRPnLLoss = 0;
maxATRPnL = minATRPnL = 0;
// Iterate through closed trades
for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
{
ATRPnL = AddATRPnL( trade );
}
// Iterate through open positions
for( trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos() )
{
ATRPnL = AddATRPnL( trade );
}
// Generate trade list
bo.ListTrades();
// Custom Statistics on ATR PnL
avgATRPnL = IIf( countATRPnL < 1, 0.0, SumATRPnL / countATRPnL );
avgATRPnLWin = IIf( countATRPnLWin < 1, 0.0, SumATRPnLWin / countATRPnLWin );
avgATRPnLLoss = IIf( countATRPnLLoss < 1, 0.0, SumATRPnLLoss / countATRPnLLoss );
bo.AddCustomMetric( "Avg Trade (ATR)", avgATRPnL );
bo.AddCustomMetric( "Avg Win (ATR)", avgATRPnLWin );
bo.AddCustomMetric( "Avg Loss (ATR)", avgATRPnLLoss );
bo.AddCustomMetric( "ATR Profit Factor", -avgATRPnLWin / avgATRPnLLoss );
bo.AddCustomMetric( "Best Trade (ATR)", maxATRPnL );
bo.AddCustomMetric( "Worst Trade (ATR)", minATRPnL );
}