I developed a NT7-Strategy with parameters as follows:
protected override void Initialize()
{
...
CalculateOnBarClose = true;
Add(contract, PeriodType.Minute, 5);
...
}
protected override void OnBarUpdate()
{
if (Bars == null)
return;
if (BarsInProgress == 1)
{
...
}
I compiled the strategy without any errors.
I set up the strategy on a 5 minute ES-chart but I cannot enable it. An error message occurs at the output-window as follows:
"**NT** Error on calling 'OnBarUpdate' method for strategy 'OHLCStrategy/794829efae334eb0b1e2223f4e2921ef': You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."
Another strategy which a developed with the same code structure as described above works without any problem. This confuses me as the "main" definition and code is in both strategies equal. Is it possible that a small code snippet is responsible for this issue?
Could you please advise what this message indicates or what to change at the code
in order to get rid of the error message and to enable to set up the strategy?
Many thanks.
Cheers!
Rob
Comment