For reference, 'HighLow.prevHighs' is an example of the List that contains all previous swing highs (which works, I checked) and I want to copy it to the new List<double> 'highs' to easily reference it.
namespace NinjaTrader.NinjaScript.Indicators
{
public class ASR2 : Indicator
{
private HighLow highlow;
List<double> highs = new List<double>();
List<double> lows = new List<double>();
private double avgRes;
private double avgSupp;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"";
Name = "ASR2";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
Swing = 5;
SwingsToStore = 5;
AddPlot(Brushes.Green, "Resistance");
AddPlot(Brushes.Red, "Support");
}
else if (State == State.Configure)
{
}
else if (State == State.DataLoaded)
{
highlow = HighLow(Swing, SwingsToStore);
highs = HighLow(Swing, SwingsToStore).prevHighs;
lows = HighLow(Swing, SwingsToStore).prevLows;
}
}
protected override void OnBarUpdate()
{
Resistance[0] = (highlow.CurrentHigh[0] + highs[0]) / (2);
//Support[0] = (highlow.CurrentLow[0] + highlow.prevLows.Sum()) / (SwingsToStore + 1);
}
region Properties
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="Swing", Order=1, GroupName="Parameters")]
public int Swing
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="Swings To Store", Order=2, GroupName="Parameters")]
public int SwingsToStore
{ get; set; }
[Browsable(false)]
[XmlIgnore]
public Series<double> Resistance
{
get { return Values[0]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> Support
{
get { return Values[1]; }
}
#endregion
}
}
Comment