Here is the code for my custom indicator which produced the drawing on the second chart:
namespace NinjaTrader.NinjaScript.Indicators
{
public class MySwing : Indicator
{
private Swing swing = null;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "MySwing";
Calculate = Calculate.OnBarClose;
IsOverlay = false;
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;
AddPlot(new Stroke(Brushes.DimGray, 1), PlotStyle.Hash, "SwingIndicatorHigh");
AddPlot(new Stroke(Brushes.DimGray, 1), PlotStyle.Hash, "SwingIndicatorLow");
}
else if (State == State.Configure)
{
}
else if (State == State.DataLoaded) {
swing = Swing(5);
}
}
protected override void OnBarUpdate()
{
SwingIndicatorHigh[0] = swing.SwingHigh[0];
SwingIndicatorLow[0] = swing.SwingLow[0];
}
#region Properties
[Browsable(false), XmlIgnore]
public Series<double> SwingIndicatorHigh { get { return Values[0]; } }
[Browsable(false), XmlIgnore]
public Series<double> SwingIndicatorLow { get { return Values[1]; } }
#endregion
}
}

Comment