I need help using SystemPerformance, I am trying to use the SystemPerformance features in an custom add-in i develop, my add-in inherits from the NinjaTrader.Gui.Tools.NTTabPage namespace, when i instantiate and try to use SystemPerformance class the results are zero, the trade count are also zero.
I tried adding it in the OnBarUpdate function too, doesn't work there either. Am i missing something? Need the ability to get the ticks, and Pnl, after the position has closed out, for any instrument? I can't get this information when position is closed because it is null. Is there another way to get the PnL, and ticks whether in position or not? Is there way to get trades, or transaction information, isn't this what the systemperformance feature is for? Also please note, my implmention is an add-in not a strategy, etc all order are places using limit, and or market order Account.Orders.Submit function
if (isInPosition) { // GetUnrealizedProfitLoss var PnL_UnRealized_ByTicker = objPosition.GetUnrealizedProfitLoss(PerformanceUnit.Currency); var Ticks_UnRealized_ByTicker = objPosition.GetUnrealizedProfitLoss(PerformanceUnit.Ticks); var Percent_UnRealized_ByTicker = objPosition.GetUnrealizedProfitLoss(PerformanceUnit.Percent); }
else { var alltradesCollCount = _Trades.Count; // SystemPerformance.AllTrades.Count; var alltradesTradeCount = _Trades.TradesCount; // SystemPerformance.AllTrades.TradesCount; var allTradesPnLTicks = this.getAllTradesPnLTicks(); var allTradesPnLCurrency = this.getAllTradesPnLCurrency(); Debug.WriteLine($"alltradesCollCount: {alltradesCollCount}"); Debug.WriteLine($"alltradesTradeCount: {alltradesTradeCount}"); Debug.WriteLine($"allTradesPnLTicks: {allTradesPnLTicks}"); Debug.WriteLine($"allTradesPnLCurrency: {allTradesPnLCurrency}"); }
private double getAllTradesPnLCurrency() { var trades = systemPerformance.AllTrades.Where(x => x.Exit.Instrument.FullName == Instrument.FullName); if (trades.IsNullOrEmpty()) return 0; return trades.Last().ProfitCurrency; // return trades.Last().ProfitCurrency; // return trades.Last().ProfitTicks; // return trades.Last().ProfitPercent; } private double getAllTradesPnLTicks() { var trades = systemPerformance.AllTrades.Where(x => x.Exit.Instrument.FullName == Instrument.FullName); if (trades.IsNullOrEmpty()) return 0; return trades.Last().ProfitTicks; // return trades.Last().ProfitCurrency; // return trades.Last().ProfitTicks; // return trades.Last().ProfitPercent; }
Comment