I am experiencing an unexpected behavior during market playback, with chart data series using Tick Replay and calculate = OnEachTick and IsSuspendedWhileInactive=false;
I am expecting when a new bar starts, the default (unset) value of the series at index [0] will be 0.0 , the default value of a double, since the bar is new and a seriesT is supposed to have a new element (array row) for each bar on the chart.
In code, at start of the indicator class, I define the var for a private Series<double>
when state = dataLoaded, I instantiate the series using MySeries = new Series<double>(this);
The code block uses mySeries[0] ++ to increment the value of the series element
When I debug, using the output to write the value of the series at index [0] it's value seems to be a random number, and it is not equal to the value of the previous bar in the series ie [1].
I test for IsFirstTickOfBar and then print the value of the series at [0]
In this debug segment, I am using string "prc chg up" to debug the value of the series.
This is a chart using bars built every 5 seconds. (but I get the same behavior on 1 minute bars)
11:59:54.429000, prc chg up=200, prc chg dn=189 <= represents values set in code, timestamp is from OnMarketData .Time value, formatted to milliseconds 11:59:54.488000 OnMarketData event , Bar# 7248, event type: Last Bid=8203.5, Ask=8203.75, Price=8203.5, Volume=1 11:59:54.488000, prc chg up=200, prc chg dn=190 <= code incremented the value of series debugged as "prc chg dn" OBU first tick of bar <= a new bar has started based on a new OMD "Last" event rcvd with timestamp outside of the bar time constraint. 11:59:55.210000 OnMarketData event , Bar# 7249, event type: Last Bid=8203.5, Ask=8203.75, Price=8203.75, Volume=1 7250 series count <= .count of series, shows it has the same number of bars on the chart. series 0 val=182 <= shows the random number ??? it is not 0.0 nor is it the last value of the previous series element series[1] val=200 <= is as expected, the last value from the previous bar of the series debugged as "prc chg up" before incr182 after incr183 <= testing the ++ increment method 11:59:55.210000, prc chg up=183, prc chg dn=211 11:59:55.214000 OnMarketData event , Bar# 7249, event type: Last Bid=8203.5, Ask=8204, Price=8204, Volume=1 before incr183 after incr184 11:59:55.214000, prc chg up=184, prc chg dn=211 11:59:55.226000 OnMarketData event , Bar# 7249, event type: Last Bid=8204, Ask=8204.25, Price=8204.25, Volume=1 before incr184 after incr185 ad infinitum ...
I can change this behavior to do what I expect, i.e. to have the default value of [0] at the start of a new bar to be 0, by using an if (IsFirstTIckOfBar) mySeries[0] = 0.0;
But I was expecting a series to have it's newest element to start with a 0.0 value, and it would not require this additional step.
Is my assumption incorrect, or is something wrong under the hood with the way NinjaTrader sets the default value of a series newest element ?
Thank you.

.

Comment