Specifically, I'm asking about the behavior of the Calculate property of an indicator as it relates to the right-most bar on a chart when dealing only with historical data.
I see some odd behavior and just want to make sure I'm understanding correctly.
Setup: I've created a simple SMA indicator that will, in addition to plotting the SMA, print to Output each time OnBarUpdate is called.
Scenario #1: Calculate=OnBarClose
In this case, OnBarUpdate is never called for the final bar on the chart. As I understand, that's because in this mode the previous close is only processed at the open of the following bar. But with no next bar, the final bar does not get processed.
...
CurrentBar=1033, Count=1037, Close[0]=2859.75
CurrentBar=1034, Count=1037, Close[0]=2855.25
CurrentBar=1035, Count=1037, Close[0]=2853.75
Scenario #2: Calculate=OnPriceChange
In this case, OnBarUpdate IS called for the final bar. As I understand, because this is historical bar data, OnPriceChange doesn't actually cause processing at the OHL prices, but it does process "at the close" using the correct closing price for the bar.
...
CurrentBar=1034, Count=1037, Close[0]=2855.25
CurrentBar=1035, Count=1037, Close[0]=2853.75
CurrentBar=1036, Count=1037, Close[0]=2836.75
First, am I understanding this correctly?
Second, I agree with the poster of the linked thread that this is counter intuitive.
Third, I can see reasons that your developers have done it this way to handle cases where you are transitioning from historical to real-time and why you might not want to change it.
If my understanding is correct, then I should be fine if I always use Calculate=OnPriceChange for all of my historical data processing to get the behavior that most people would expect.
Finally, a suggestion:
Please consider adding discussions of this confusion to the help documentation on both the Calculate page (https://ninjatrader.com/support/help...?calculate.htm) and the OnBarUpdate page (https://ninjatrader.com/support/help...nbarupdate.htm).
Postscript: The timeouts on this website are way too short. I lost all my work on this post, but luckily anticipated that I might be logged out and copied it before I tried to submit. The login attempted to redirect me back to my new thread page, but it was empty.
Comment