I am trying to display the value of the PnL for the most recent trade
if (SystemPerformance.AllTrades.Count > 0){ Trade lastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1]; Draw.Text(this, @"rP"+CurrentBar, ""+lastTrade.ProfitCurrency, 0, Low[0]+5, Brushes.Yellow); Print("Last trade PnL: "+lastTrade.ProfitCurrency); }
What happens is, if I have four trades, the first trade is ignored and the final three are labeled with text but the values on each correspond to the earlier draw event. So when it should output:
Trade 1 - $10
Trade 2 - $20
Trade 3 - $10
Trade 4 - $40
instead I get:
Trade 1 -
Trade 2 - $10
Trade 3 - $20
Trade 4 - $10
I tried using
Trade lastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count];
What am I doing wrong?
Comment