I think that there is an inconsistency about when OnStateChange() is called.
First case :
I have a simple chart with a single indicator. Now I add a secondary bar series via the DataSeries menu.
Result: The new bar series appears on a second panel below the old bar series. The indicator on the upper panel is recalculated. Both OnStateChange() and OnBarUpdate() are called.
Second case:
I have the same simple chart with a single indicator. Now I change the bar properties from "equidistant bar spacing" to "non-equidistant bar spacing".
Result: The indicator is only partly recalculated. OnStateChange() is not being executed, while OnBarUpdate() is called.
Inconsistency:
In both cases the bar spacing of the primary bars is changed. However,
- when a secondary bar series is added to the chart, both OnStateChange() and OnBarUpdate() are called for the indicator applied to the primary bars
- when the bar spacing is changed only OnBarUpdate() is called for the same indicator
I think that it is necessary to call both OnStateChange() and OnBarUpdate(), when the bar spacing property is changed. This is necessary as it is best practice to test for bar properties when State == State.Historical within OnStateChange(). Not calling OnStateChange() in this case is a major omission.
Comment