The Bottom and Hat square lines work fine. But the FlipUp and FlipDown can not be referred to in the strategy.
Thanks
namespace NinjaTrader.Indicator { /// <summary> /// High Low Activator /// </summary> [Description("High Low Activator")] public class AIndiTester : Indicator { #region Variables // Wizard generated variables private int period = 5; // Default setting for Period // User defined variables (add any user defined variables below) private double Havg,Lavg; private int swing,previous_swing; private DataSeries flipUp,flipDown; #endregion /// <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.OrangeRed), PlotStyle.Square, "Hat")); Add(new Plot(Color.FromKnownColor(KnownColor.Lime), PlotStyle.Square, "Bottom")); flipUp=new DataSeries(this); flipDown=new DataSeries(this); Overlay = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (CurrentBar< period+1 ) return; Havg=SMA(High,period)[1]; Lavg=SMA(Low,period)[1]; if(Input[0]<Lavg) swing = -1; if(Input[0]>Havg) swing = 1; if (swing==-1) { FlipDown.Set(0); Hat.Set(Havg); if (previous_swing!=swing) FlipDown.Set(1); } if (swing==1) { FlipUp.Set(0); Bottom.Set(Lavg); if (previous_swing!=swing) FlipUp.Set(1); } previous_swing=swing; } #region Properties [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries Hat { get { return Values[0]; } } [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries Bottom { get { return Values[1]; } } [Description("")] [GridCategory("Parameters")] public int Period { get { return period; } set { period = Math.Max(1, value); } } public DataSeries FlipDown { get {return Values[3];} } public DataSeries FlipUp { get {return Values[2];} } #endregion } }
Comment