I have two issues
1. How can i make sure to remove the falling stick of the ema indicator see attachment
2. ema89 is not plotting. Why?
namespace NinjaTrader.NinjaScript.Indicators { public class EMAon5minData : Indicator { private EMA EMA34, EMA89; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "EMAon5minData"; 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; AddPlot(Brushes.Orange, "EMAPlot34"); AddPlot(Brushes.Cyan, "EMAPlot89"); } else if (State == State.Configure) { AddDataSeries(this.Instrument.FullName, new BarsPeriod { BarsPeriodType = (BarsPeriodType)2018, BaseBarsPeriodValue = 10, Value = 10, Value2 = 50 }); } else if (State == State.DataLoaded) { EMA34 = EMA(BarsArray[1], 34); //set EMA here so we make sure it's calculated on the secondary data series EMA89 = EMA(BarsArray[1], 89); } } protected override void OnBarUpdate() { if (CurrentBars[0] < 1 || CurrentBars[1] < 20) // make sure there's at least one bar for primary series and at least 20 of the secondary series prior to processing return; if(BarsInProgress == 0) // if OnBarUpdate was called from the primary bar series, then set the current value to the latest EMA1 value Value[0] = EMA34[0]; Value[1] = EMA89[0]; } #region Properties [Browsable(false)] [XmlIgnore] public Series<double> EMAPlot34 { get { return Values[0]; } } [Browsable(false)] [XmlIgnore] public Series<double> EMAPlot89 { get { return Values[1]; } } #endregion } }
Comment