I would like to report a bug.
Version:
8.0.27.1 (Tested on a clean installation)
Description
When enabling an Unmanaged strategy, it will often not respect the Trading Hours Template. It will enter a position immediately after enabling the strategy. Even if the market is closed or when chart is showing historical bars from the past.
Steps to Reproduce
1. Open a new Chart and set the data Series to the following values:
Instrument: NQ
Timeframe: 1 minute
Days to Load: 3
End Date: 24/02/2023
Trading Hours: CME US Index Futures RTH
2. Add the Ninjatrader Unmanaged Template Example Strategy (attached) to the chart and enable.
Expected Result
The strategy should not submit live orders because the chart is outside of the trading hours template: it is after close on a Friday. Furthermore, the chart is displaying historical bars from the past so it should not enter a position based on these bars.
Actual Result
The strategy Immediately places limit orders to enter the market, The Orders are based on the historical bars. The market has moved since then and therefore the order entry price is wrong and the orders are placed on the wrong side of the market, they fill immediately and place the strategy in an unexpected erroneous position.
Additional Information
1. The same result occurs if the chart shows today's bars but the market is closed. For example when using the US Equities RTH template which ends at 4pm ET. If you enable a strategy after 4pm ET with this trading hours template, it will submit an order.
2. If the strategy is updated to add "Print(State)" to OnBarUpdate, the strategy State does not reach Transition or Realtime. The output of this is below:
... Historical Historical Historical Historical Historical Historical Enabling NinjaScript strategy 'UnmanagedTemplate/288971050' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=True MaxRestarts=4 in 5 minutes NinjaScript strategy 'UnmanagedTemplate/288971050' submitting order NinjaScript strategy 'UnmanagedTemplate/288971050' submitting order

Comment