I want to set an indicator value based on the values of the previous bar .... (this is so i can access it in the market analyzer). Unfortunately this does not seem to work using [1] in the last if block ... how can i do this i need to access the characteristics of the previous bar in the market analyser
thanks
public class RangeAnalysis : Indicator
{
#region Variables
// Wizard generated variables
private int period = 20; // Default setting for Period
// User defined variables (add any user defined variables below)
#endregion
private DataSeries Range;
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Bar, "BarRange"));
Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "UpperOneRange"));
Add(new Plot(Color.FromKnownColor(KnownColor.Firebrick), PlotStyle.Line, "LowerOneRange"));
Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "UpperTwoRange"));
Add(new Plot(Color.FromKnownColor(KnownColor.Firebrick), PlotStyle.Line, "LowerTwoRange"));
Add(new Plot(Color.FromKnownColor(KnownColor.Yellow), PlotStyle.Line, "AveRange"));
Add(new Plot(Color.FromKnownColor(KnownColor.Transparent), PlotStyle.Line, "RangeIndicator"));
CalculateOnBarClose = false;
Overlay = false;
PriceTypeSupported = false;
Range = new DataSeries(this);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Range[0] = High[0] - Low[0];
BarRange.Set(Range[0]);
UpperOneRange.Set(1.5*SMA(Range,Period)[0]);
LowerOneRange.Set(0.5*SMA(Range,Period)[0]);
UpperTwoRange.Set(2.0*SMA(Range,Period)[0]);
LowerTwoRange.Set(0.25*SMA(Range,Period)[0]);
AveRange.Set(SMA(Range,Period)[0]);
/// if i use [0] here it works but i want the values of RangeIndicator to be based on the previous bars values ...
if (Range[1] >= UpperTwoRange[1]) RangeIndicator.Set(2);
else if (Range[1] >= UpperOneRange[1]) RangeIndicator.Set(1);
else if (Range[1] <= LowerTwoRange[1]) RangeIndicator.Set(-2);
else if (Range[1] <= LowerOneRange[1]) RangeIndicator.Set(-1);
else RangeIndicator.Set(0);
}

Comment