I am getting this below error:
"Strategy name: Error on calling 'OnStateChange' method: index was outside the bounds of the array". I have already checked your other forum posts realted to it and nothings sovles the error issue. Before you suggest me, I have alrady used print to debug and also used VS to find where its getting the null.
I am enabling the strategy and running on market replay data. after running it for sometime, when I am changing the market replay data date to the past, it is disabling the strategy and not re-enabling the strategy and showing the error, unlike other strategies doing the same.
Please find my prints and place where the null value is coming from below:
protected override void OnStateChange()
{
Print(0);
if (State == State.SetDefaults)
{
}
else if (State == State.Configure)
{
Print(1);
AddDataSeries(); // This is where the null value is coming from.
}
else if (State == State.Historical)
{
Print(2);
}
else if (State == State.Transition)
{
Print(3);
}
else if (State == State.DataLoaded)
{
Print(4);
}
else if (State == State.Terminated)
{
Print(5);
}
Print(6+"====================================");
}
When I first enable and run the strategy, it print starting with 0 and ends with 6, but when I change the market replay data, it only prints 6, never goes to 0. With help of VS, I found below is giving null value:
else if (State == State.Configure)
{
Print(1);
AddDataSeries(); // This is where the null value is coming from.
}
In AddDataSerires, I am using ChartBars.ToIndex to calculate no of barstoload.
Looking forward to your reply.
Comment