Finding symbol name of last trade

I am using multi products to backtest. I know name() can get the current symbol name but how can I know the symbol name of last completed trade (closed position ) ? Thanks

You can pick this up using the high-level custom backtester and display it on the backtest report.

MA1 = MA(C, 5);
MA2 = MA(C, 10);
Buy = Cross(MA1, MA2);
Sell = Cross(MA2, MA1);

SetCustomBacktestProc(""); 
if( Status("action") == actionPortfolio ) 
{ 
     bo = GetBacktesterObject(); 
     bo.Backtest(); // run default backtest procedure 

    for (trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade())
    {
		LastTradeSymbol = trade.Symbol;
    }
	bo.AddCustomMetric("Last Completed Trade Symbol", LastTradeSymbol);
}

image

Thank you so much
actually , I have buy selll cover and short signal. I want to double the sizing if I know the current symbol is as same as the last symbol of trade. How can I do that?? Thanks

That’s a little more complex than your initial query.

You can use the Mid-Level custom backtester to achieve that. On each bar, find the symbol of the last closed trade, as above. Then loop through the signal list to see if that symbol has an entry signal. If it does, you can increase its size using sig.PosSize, before processing the trade signals.

If you’re unfamiliar with the custom backtester, you can start by reading this.