else if (State == State.Configure) {
int daysToLoad = (int)(ChartBars.Bars.ToDate - ChartBars.Bars.FromDate).TotalDays + 1;
var barsPeriodDay = new BarsPeriod() { BarsPeriodType = BarsPeriodType.Day, Value = 1 };
var tradingHours = ChartBars.Bars.TradingHours.ToString();
AddDataSeries(Instrument.FullName, barsPeriodDay, 11, tradingHours, null);
}
But, the first time I enables the code, the following null reference exception occurred. ( I re-enables it on the same chart, it works fine.)
Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
I know that in "Best Practice" section, we should wait using ChartBars until the state has reached State.Historical, but on the other hand, AddDataSeries must be call in State.Configure. So is there any way to achieve this properly ?
Comment