I am attempting to use the stop price of a cancelled stop order to perform calculations in a custom performance metric. I am stumped on how to retrieve this data in the Performance Metric class. In theory, this class includes an array of order strings since it is using NinjaTrader.Gui.TradePerformance and I can see all the orders in the Trade Performance window. I have made some attempts to access OrdersGrid and OrdersGridEnty but I can't figure it out.
The basic data gap I'm trying to solve is on profitable trades, the trade.Entry.Order.StopPrice and the trade.Exit.Order.StopPrice are both zero based on the managed approach I generally use to enter trades and exit trades.
General entry code from strategy:
SetProfitTarget(Name + "Entry" + counter, CalculationMode.Price, ProfitTarget);
SetStopLoss(Name + "Entry" + counter, CalculationMode.Price, MIN1[0], false);
EnterLong(1, Name + "Entry" + counter);
General exit code from strategy:
ExitLong(1, @"partial" + partials, Name + "Entry" + partials);
This all works to my satisfaction in execution, and when a partial ExitLong executes, the associated StopLoss order is cancelled. However, I would like to record and use that StopLoss price to do calculations in a custom Performance Metric.
I cannot call OnOrderUpdate() from a custom Performance Metric, so I figured the next best thing is to access data in the OrderGrid or OrderGridEntry arrays.
Do you have any coding techniques to properly access the array of string data in the NinjaTrader.Gui.TradePerformance OrderGrid or OrderGridEntry from the PerformanceMetric class?
Any ideas would be appreciated.
Comment