For some reason, it does not work
Here is below the script :-)
namespace NinjaTrader.NinjaScript.Indicators
{
public class intraDayMA : Indicator
{
private SMA sma;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "intraDayMA";
Calculate = Calculate.OnPriceChange;
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;
Period = 3;
AddPlot(new Stroke(Brushes.Green,0), PlotStyle.Line, "Daily MA");
}
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Day, 1);
}
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] < 1 || CurrentBars[1] < Period) return;
double myPlot = SMA(BarsArray[1], Period-1)[1];
myPlotLine[0] = (myPlot * (Period - 1) + Close[0]) / Period;
}
#region Properties
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="Period", Order=1, GroupName="Parameters")]
public int Period
{ get; set; }
[Browsable(false)]
[XmlIgnore]
public Series<double> myPlotLine
{
get { return Values[0]; }
}
#endregion
}
}
If anyone can help me, I would be greatfull.
Thanks

Comment