Backtester showing wrong number of shares


#1

I was adding some custom metrics relating to shares and price when I noticed that the number of shares being reported and returned by trade.Shares() is too high. Can anyone shed some light on this? It happens across all of my trading model backtests, not just one.

Below you will see that Entry Price * Shares does not equal Entry Value. Same goes for Exits. All other values reported are fine except for number of shares.

Capture


#2

Code below used to generate the custom metrics.

if( Status( "action" ) == actionPortfolio )
{
	bo = GetBacktesterObject();
	bo.backtest( True );
	st = bo.GetPerformanceStats( 0 );
	
	for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() ) {
		trade.AddCustomMetric( "Comission", trade.GetCommission() );
		trade.AddCustomMetric( "Shares", trade.Shares(), 0 );
		trade.AddCustomMetric( "Entry Price", trade.EntryPrice() );
		trade.AddCustomMetric( "Entry Price * Shares", trade.Shares() * trade.EntryPrice() );
		trade.AddCustomMetric( "Entry Value", trade.GetEntryValue() );
		trade.AddCustomMetric( "Exit Price", trade.ExitPrice() );
		trade.AddCustomMetric( "Exit Price * Shares", trade.Shares() * trade.ExitPrice() );
		trade.AddCustomMetric( "Exit Value", trade.GetPositionValue() );
	}
}

#3

I found the problem.

Under Preferences and Currencies I changed the base currency to my local currency. Note: I did not have Trade using FX cash conversion ticked.