I am working on an indicator that detects a certain pattern and then draws a dot below the bar where the pattern was confirmed.
Because the pattern can easily start in historical time and complete in real time I need to account for the crossover. In trying to work through that logic I have Print statements at various junctures.
I am testing this in replay mode with volume bars (which may account for what I see) I noticed NinjaTrader appears to recognize the last full bar as the first real time bar.
if (Historical == true)
Print("Historical bar " + Time[0]);
else
Print("Real time bar " + Time[0]);
On the first real time bar, print Time[0] and I get the close time of the last bar; all the historical bars show the right time. I am aligning this with the replay clock and using the session break in the futues i.e. I am starting the replay on a Sunday at 1801 (Eastern) and I am getting 1659 (close of the previous bar) on the previous Friday as the first real time bar.
Is this because on the first tick of the bar in real time Time[0] is the last tick of the previous bar? I can understand that under most conditions but on a session break that doesn't seem correct.
I don't particularly care how NinjaTrader decided to handle this, I only want to verify I don't have an issue in my code.
As an aside, I have found having a bars ago offset that is set based on the bar's historical status and then added to every bars ago index - Close[2 + barsAgoOffset] works really well. For historical bars the offset is 0 and for real time bars it is 1. When used in conjunction with FirstTickOfBar the crossover is handled correctly.
Any suggestions will be appreciated.
Best Regards,
Scott
Comment