As the title indicates, I'm hoping to ask for some guidance when it comes to how Ninjatrader transitions from Historical to Realtime data. Here's the situation I'm struggling with... I set off my strategy which uses 10 sec bars and run it in demo mode (it pulls some historical data then when up to date starts processing realtime data). For each bar I print various datapoints (including CurrentBar) to a file. I then shut off the strategy and immediate run Strategy Analyzer over the same time period, and when I look at the prints for the Strategy Analyzer and Live-Demo, I see different Bar counts for each time. For example:
In my Strategy Analyzer run: Time: 7/25/2022 3:04:30 PM, Ticker: AEMD, State: Historical, boughtToday: True, cutOff: False, regMarketClose: 1.06, CurrentBars[0]: 922, _lastOrderBar: 232
In my Live-Demo run: Time: 7/25/2022 3:04:30 PM, Ticker: AEMD, State: Realtime, boughtToday: True, cutOff: False, regMarketClose: 1.06, CurrentBars[0]: 923, _lastOrderBar: 232
I remember that NinjaTrader_Jim used some offset logic within his BuySellVolumeOneTick example, however despite following the code annotations I'm really struggling to understand why the CurrentBar count is different between Backtests & Live (e.g. for 3:04:30 PM why is one showing 922 and another 923?). Would anyone be able to help me please with a dumbed down explanation of why CurrentBars differs between realtime and historical (or more literally, a strategy that pulls historical data then transitions to realtime, vs just historical backtests). My trades aren't firing in realtime and this CurrentBars discrepancy seems to be the root cause (other datapoints are different but it all seems to stem from the same CurrentBars issue).
Many thanks in advance
ChainsawDR

Comment