A common programming error is not checking to ensure there are enough bars contained in the data series you are accessing. This will explain some of the concepts to check for this situation,
For example:
protected override void OnBarUpdate() { if (Close[0] > Close[1]) // Do something }
On the very first bar (think of the 1st bar on the chart from left to right) the value of "close of 1 bar ago" (Close[1]) does not yet exist and your indicator/strategy will not work and throw an exception to the Control Center Log tab "Index was out of range...".
Following are two ways to ways to resolve this:
protected override void OnBarUpdate() { [COLOR=BLUE][B]if (CurrentBar < 1) return;[/B][/COLOR] if (Close[0] > Close[1]) // Do something }
protected override void OnBarUpdate() { if (Close[0] > Close[[COLOR=BLUE][B]Math.Min(CurrentBar, 1)[/B][/COLOR]]) // Do something }