PDA

View Full Version : Array Index Errors in Help Guide


KBJ
12-16-2007, 04:35 PM
There are several typos in the help relating to needed array indices...


Plots

Definition

A collection holding all of the Plot objects that define the visualization characteristics of the indicator.

Property Value

A collection of Plot objects.

Syntax

Plots[int index]

Examples

// Initialize method of a custom indicator
protected override void Initialize()
{
// Plots are added to the Plots collection in order
Add(new Plot(Color.Orange, "Plot1")); // Stored in Plots[0]
Add(new Plot(Color.Blue, "Plot2")); // Stored in Plots[1]
}

// Dynamically change the primary plot's color based on the indicator value
protected override void OnBarUpdate()
{
if (Values[0] > 100)
Plots[0].Pen = new Pen(Color.Blue);
else
Plots[0].Pen = new Pen(Color.Red);
}
Since "Values" is defined as an array of Dataseries, the correct reference should be either "Value[0]" or "Values[0][0]".

Similar errors occur in the help guide example for "Value"...


Value

Definition

Value references the 1st DataSeries object Values[0] in the indicator. This is the primary indicator value.

Property Value

A DataSeries object.

Syntax

Value

Examples

// OnBarUpdate method of a custom indicator
protected override void OnBarUpdate()
{
// Checks the indicator primary value 1 bar aga and sets the value of the indicator
// for the current bar being evaluated
if (Values[1] < High - Low)
Value.Set(High - Low);
else
Value.Set(High - Close);
}...the references "Values[1]" and "High" and "Low" all need an[other] array index (e.g., Values[0][1], High[0], Low[0]).

NinjaTrader_Ray
12-16-2007, 09:12 PM
Thanks for pointing this out. Will take care of it.