It seems in all cases, no matter what the Calculate setting, OnBarUpdate is triggered only when the first tick arrives after the real-time end of the Bar in progress.
For example, if the BarsPeriod is 60 Minutes and the 60 Minute real-time period elapses (i.e. the top of the hour arrives), if the market is very slow and the next tick does not arrive for, say, 2 Minutes (an exaggerated period perhaps, but still possible), OnBarUpdate will not trigger until 2 minutes after the hour.
This example is of little consequence for Calculate.OnEachTick and Calculate.OnPriceChange, since these both are explicitly tick-dependent.
For Calculate.OnBarClose though, it is more problematic, since one can interpret BarClose as "the real-time period of BarsPeriod has elapsed NOW in real-time". This is not tick-dependent. In this case, I would contend that triggering OnBarUpdate should be tied to real-time, not the next tick after the elapsed real-time. That is certainly my view of the "correct" behaviour.
If NinjaTrader agrees this is indeed the behaviour that occurs (please correct me if I have misunderstood anything), I believe there should be (at least) two changes to make the behaviour more able to cater for real-time requirements:
- An additional Calculate setting of Calculate.OnRealTimeElapsed is warranted. The behaviour would be to trigger OnBarUpdate in real-time as the BarsPeriod elapses.
- With such a new Calculate setting, the closing Bar should be closed/completed in real-time, not when the next tick arrives, and all Bar attributes (OHLC etc) should be immediately available.
Thanks.
Comment