Hi all,
I'm trying to get year from trade.EntryPrice (in the loop below), in the format of 2014 (YYYY). Is there an easy way? Been looking around but now found anything that works in the GetBacktesterObject context.
SetCustomBacktestProc("");
if( Status("action") == actionPortfolio )
{
bo = GetBacktesterObject();
bo.Backtest(1); // run default backtest procedure
// iterate through closed trades first
for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
{
symbolRisk = StaticVarGet( trade.Symbol + "Risk" );
entryRisk = Lookup( symbolRisk, trade.EntryDateTime );
RMultiple = (trade.ExitPrice() - trade.EntryPrice()) / entryRisk;
SumProfitPerRisk = SumProfitPerRisk + RMultiple;
NumTrades++;
trade.AddCustomMetric("R-multiple", RMultiple);
//TODO: Get year from trade.EntryPrice()
// Wished result: 2014... :(
}
bo.ListTrades();
}