When backtesting, this is what I see, and is what I expect:
Position Opened
Position Closed
Last Trade PL = ($35.00)
.....
This indicates that SystemPerformance.AllTrades is not being populated when a live strategy is run on historical bars. Not sure if this is a bug or I am misusing something, but since I'm not using SystemPerformance.RealTimeTrades, I would have expected it to include historical trades as well.
I have gotten here by trying to debug. Initially, I tried the following without the nested if statement as I assumed that the second Print() would only be called when a trade is exited (and thus AllTrades.Count having at least 1 item) but this caused NT8 to not respond/force close on me.
if (execution.Order.Name.Substring(0,4) == "Exit") { Print("Position Closed"); if (SystemPerformance.AllTrades.Count > 0) Print("Last Trade PL = " + SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1].ProfitCurrency.ToString("C")); }
Comment