As a part of my strategy I need to access P&L of the last two trades. The code is very simple and I am using it on $EURUSD.
As you can see below, I am trying store P&L of my "Long1" and "Short1" entry signals to two different TradeCollection objects - myTrades and myTrades1. The challenge is when I see the Output window, I can see the strategy printing P&L for my "Long1" entrysignal but nothing for "Short1" entrysignal.
I am backtesting the concept in Market Replay mode. Why can I see the P&L for Long1 signal but not for Short1. Any idea what could be wrong?
if (Historical)
return;
if (CrossAbove(SMA(Fast), SMA(Slow), 1))
{
EnterLong(1000,"Long1");
}
if (CrossBelow(SMA(Fast), SMA(Slow), 1))
{
EnterShort(1000,"Short1");
}
TradeCollection myTrades = Performance.AllTrades.GetTrades("$EURUSD", "Long1", 1);
TradeCollection myTrades1 = Performance.AllTrades.GetTrades("$EURUSD", "Short1", 1);
Print("Profit for the last Long1 trade is: $"+myTrades.TradesPerformance.Currency.AvgProfi t);
Print("Profit for the last Short1 trade is: $"+myTrades1.TradesPerformance.Currency.AvgProfit) ;
Comment