Have a strategy that uses StartAtmStrategy(Via custom button click):
private void OnBuyLongClick(..) { Order eo = Account.CreateOrder(Instrument, OrderAction.Buy, OrderType.Limit, OrderEntry.Manual, TimeInForce.Day, 3, limitPrice, 0, string.Empty, "Entry", Core.Globals.MaxDate, null); atmStrategy = NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy(ATMLongMan, eo); Print(atmStrategy.IncludeTradeHistoryInBacktest); //False }
But there are never any trades.
All the expected executions are there (ATM entry executions and ATM exit executions via atm targets or atm stops)
OnBarUpdate(..) { if (atmStrategy != null) { OrderState os = atmStrategy.InitialEntryOrder.OrderState; int posQuantity = 0; if (atmStrategy.Positions != null) { // Only check Position property if Positions != null, otherwise CRASH posQuantity = atmStrategy.Position.Quantity; } // Trade was filled, but we no longer have a position, so it is complete, and we should have trades if ((os == OrderState.Filled || os == OrderState.PartFilled) && posQuantity == 0) { Print("ATM Trades Count: " + atmStrategy.SystemPerformance.AllTrades.Count()); Print("ATM Realized PnL " + atmStrategy.SystemPerformance.RealTimeTrades.Trade sPerformance.Ticks.CumProfit); Print("Atm Executions: " + atmStrategy.Executions.Count); //In my test, all the expected executions open and close executions are present }
Any ideas ?
Anything I can call with a list of executions that will calc realized PnL ? I know I can do it by hand
BTW, AtmStrategyCreate() and the ATM Monitoring calls work as expected, but that has other limitations( no way to resume monitoring for running ATMs if the strategy stops and has to be restarted),
Comment