Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Ninja ElliottOscillator Editing Question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Ninja ElliottOscillator Editing Question

    Can someone let me know how I could edit the elliottoscillator so that if it's above the zero line it's one color (green) and if it's below the zero line it's one color (red)...no neutral readings...thanks

    #2
    thesoyboy2, would you mind attaching the code you refer to so we could review and advice?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      here you go...thanks

      //
      // Copyright (C) 2006, NinjaTrader LLC <[email protected]>.
      // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
      //

      #region Using declarations
      using System;
      using System.Diagnostics;
      using System.Drawing;
      using System.Drawing.Drawing2D;
      using System.ComponentModel;
      using System.Xml.Serialization;
      using NinjaTrader.Data;
      using NinjaTrader.Gui.Chart;
      #endregion

      // This namespace holds all indicators and is required. Do not change it.
      namespace NinjaTrader.Indicator
      {
      /// <summary>
      /// Elliot Oscillator
      /// </summary>
      [Description("The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.")]
      [Gui.Design.DisplayName("Elliot Oscillator")]
      public class ElliotOscillator : Indicator
      {
      #region Variables
      private int fast = 5;
      private int slow = 34;
      private double elliot = 0;
      private double elliot3 = 0;
      private DataSeries fastEma;
      private DataSeries slowEma;
      #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.Transparent, "Elliot"));
      Add(new Plot(new Pen(Color.Black, 3), PlotStyle.Bar, "Neutral"));
      Add(new Plot(new Pen(Color.Blue, 3), PlotStyle.Bar, "UpTrend"));
      Add(new Plot(new Pen(Color.Red, 3), PlotStyle.Bar, "DownTrend"));
      Add(new Plot(Color.Red, "Elliot Displaced"));

      Add(new Line(Color.DarkGray, 0, "Zero line"));

      fastEma = new DataSeries(this);
      slowEma = new DataSeries(this);
      CalculateOnBarClose = true;
      PriceTypeSupported = true;
      AutoScale = true;
      }

      /// <summary>
      /// Calculates the indicator value(s) at the current index.
      /// </summary>
      protected override void OnBarUpdate()
      {
      if (CurrentBar < 3)
      return;
      if (CurrentBar == 0)
      {
      fastEma.Set(Input[0]);
      slowEma.Set(Input[0]);
      Value.Set(0);
      Elliott3.Set(0);


      if (SMA(100)[0] > SMA(200)[0] && SMA(20)[0] > SMA(100)[0])
      Uptrend.Set(0);
      else if (SMA(100)[0] < SMA(200)[0] && SMA(20)[0] < SMA(100)[0])
      Downtrend.Set(0);
      else
      Neutral.Set(0);
      }
      else
      {
      fastEma.Set(SMA(fast)[0]);
      slowEma.Set(SMA(slow)[0]);
      elliot = ((fastEma[0] - slowEma[0]));
      elliot3 = ((fastEma[3] - slowEma[3]));

      Value.Set(elliot);
      Elliott3.Set(elliot3);


      if (SMA(100)[0] > SMA(200)[0] && SMA(20)[0] > SMA(100)[0])
      Uptrend.Set(elliot);
      else if (SMA(100)[0] < SMA(200)[0] && SMA(20)[0] < SMA(100)[0])
      Downtrend.Set(elliot);
      else
      Neutral.Set(elliot);
      }


      }

      #region Properties
      /// <summary>
      /// </summary>
      [Browsable(false)]
      [XmlIgnore()]
      public DataSeries Default
      {
      get { return Values[0]; }
      }
      /// <summary>
      /// </summary>
      [Browsable(false)]
      [XmlIgnore()]
      public DataSeries Neutral
      {
      get { return Values[1]; }
      }
      [Browsable(false)]
      [XmlIgnore()]
      public DataSeries Uptrend
      {
      get { return Values[2]; }
      }

      [Browsable(false)]
      [XmlIgnore()]
      public DataSeries Downtrend
      {
      get { return Values[3]; }
      }

      /// <summary>
      /// </summary>
      [Browsable(false)]
      [XmlIgnore()]
      public DataSeries Elliott3
      {
      get { return Values[4]; }
      }




      /// <summary>
      /// </summary>
      [Description("Number of bars for fast SMA")]
      [Category("Parameters")]
      public int Fast
      {
      get { return fast; }
      set { fast = Math.Max(1, value); }
      }

      /// <summary>
      /// </summary>
      [Description("Number of bars for slow SMA")]
      [Category("Parameters")]
      public int Slow
      {
      get { return slow; }
      set { slow = Math.Max(1, value); }
      }

      #endregion
      }
      }

      #region NinjaScript generated code. Neither change nor remove.
      // This namespace holds all indicators and is required. Do not change it.
      namespace NinjaTrader.Indicator
      {
      public partial class Indicator : IndicatorBase
      {
      private ElliotOscillator[] cacheElliotOscillator = null;

      private static ElliotOscillator checkElliotOscillator = new ElliotOscillator();

      /// <summary>
      /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
      /// </summary>
      /// <returns></returns>
      public ElliotOscillator ElliotOscillator(int fast, int slow)
      {
      return ElliotOscillator(Input, fast, slow);
      }

      /// <summary>
      /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
      /// </summary>
      /// <returns></returns>
      public ElliotOscillator ElliotOscillator(Data.IDataSeries input, int fast, int slow)
      {
      if (cacheElliotOscillator != null)
      for (int idx = 0; idx < cacheElliotOscillator.Length; idx++)
      if (cacheElliotOscillator[idx].Fast == fast && cacheElliotOscillator[idx].Slow == slow && cacheElliotOscillator[idx].EqualsInput(input))
      return cacheElliotOscillator[idx];

      lock (checkElliotOscillator)
      {
      checkElliotOscillator.Fast = fast;
      fast = checkElliotOscillator.Fast;
      checkElliotOscillator.Slow = slow;
      slow = checkElliotOscillator.Slow;

      if (cacheElliotOscillator != null)
      for (int idx = 0; idx < cacheElliotOscillator.Length; idx++)
      if (cacheElliotOscillator[idx].Fast == fast && cacheElliotOscillator[idx].Slow == slow && cacheElliotOscillator[idx].EqualsInput(input))
      return cacheElliotOscillator[idx];

      ElliotOscillator indicator = new ElliotOscillator();
      indicator.BarsRequired = BarsRequired;
      indicator.CalculateOnBarClose = CalculateOnBarClose;
      #if NT7
      indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
      indicator.MaximumBarsLookBack = MaximumBarsLookBack;
      #endif
      indicator.Input = input;
      indicator.Fast = fast;
      indicator.Slow = slow;
      Indicators.Add(indicator);
      indicator.SetUp();

      ElliotOscillator[] tmp = new ElliotOscillator[cacheElliotOscillator == null ? 1 : cacheElliotOscillator.Length + 1];
      if (cacheElliotOscillator != null)
      cacheElliotOscillator.CopyTo(tmp, 0);
      tmp[tmp.Length - 1] = indicator;
      cacheElliotOscillator = tmp;
      return indicator;
      }
      }
      }
      }

      // This namespace holds all market analyzer column definitions and is required. Do not change it.
      namespace NinjaTrader.MarketAnalyzer
      {
      public partial class Column : ColumnBase
      {
      /// <summary>
      /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
      /// </summary>
      /// <returns></returns>
      [Gui.Design.WizardCondition("Indicator")]
      public Indicator.ElliotOscillator ElliotOscillator(int fast, int slow)
      {
      return _indicator.ElliotOscillator(Input, fast, slow);
      }

      /// <summary>
      /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
      /// </summary>
      /// <returns></returns>
      public Indicator.ElliotOscillator ElliotOscillator(Data.IDataSeries input, int fast, int slow)
      {
      return _indicator.ElliotOscillator(input, fast, slow);
      }
      }
      }

      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Strategy
      {
      public partial class Strategy : StrategyBase
      {
      /// <summary>
      /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
      /// </summary>
      /// <returns></returns>
      [Gui.Design.WizardCondition("Indicator")]
      public Indicator.ElliotOscillator ElliotOscillator(int fast, int slow)
      {
      return _indicator.ElliotOscillator(Input, fast, slow);
      }

      /// <summary>
      /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
      /// </summary>
      /// <returns></returns>
      public Indicator.ElliotOscillator ElliotOscillator(Data.IDataSeries input, int fast, int slow)
      {
      if (InInitialize && input == null)
      throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

      return _indicator.ElliotOscillator(input, fast, slow);
      }
      }
      }
      #endregion

      Comment


        #4
        Thanks, think what you seek would just be a minor change to do the coloring based on the <> 0 condition for the main oscillator value - i.e. change the part in OnBarUpdate() where you assign the plots to -

        if (Value[0] > 0)
        Uptrend.Set(elliot);
        else if (Value[0] < 0)
        Downtrend.Set(elliot);
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I did what you suggested (not sure if I did it correctly) but neutral still shows up on the chart?

          //
          // Copyright (C) 2006, NinjaTrader LLC <[email protected]>.
          // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
          //

          #region Using declarations
          using System;
          using System.Diagnostics;
          using System.Drawing;
          using System.Drawing.Drawing2D;
          using System.ComponentModel;
          using System.Xml.Serialization;
          using NinjaTrader.Data;
          using NinjaTrader.Gui.Chart;
          #endregion

          // This namespace holds all indicators and is required. Do not change it.
          namespace NinjaTrader.Indicator
          {
          /// <summary>
          /// Elliot Oscillator
          /// </summary>
          [Description("The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.")]
          [Gui.Design.DisplayName("Elliot Oscillator")]
          public class ElliotOscillatorTEST : Indicator
          {
          #region Variables
          private int fast = 5;
          private int slow = 34;
          private double elliot = 0;
          private double elliot3 = 0;
          private DataSeries fastEma;
          private DataSeries slowEma;
          #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.Transparent, "Elliot"));
          Add(new Plot(new Pen(Color.Black, 3), PlotStyle.Bar, "Neutral"));
          Add(new Plot(new Pen(Color.Blue, 3), PlotStyle.Bar, "UpTrend"));
          Add(new Plot(new Pen(Color.Red, 3), PlotStyle.Bar, "DownTrend"));
          Add(new Plot(Color.Red, "Elliot Displaced"));

          Add(new Line(Color.DarkGray, 0, "Zero line"));

          fastEma = new DataSeries(this);
          slowEma = new DataSeries(this);
          CalculateOnBarClose = true;
          PriceTypeSupported = true;
          AutoScale = true;
          }

          /// <summary>
          /// Calculates the indicator value(s) at the current index.
          /// </summary>
          protected override void OnBarUpdate()
          {
          if (CurrentBar < 3)
          return;
          if (CurrentBar == 0)
          {
          fastEma.Set(Input[0]);
          slowEma.Set(Input[0]);
          Value.Set(0);
          Elliott3.Set(0);


          if (Value[0] > 0)
          Uptrend.Set(elliot);
          else if (Value[0] < 0)
          Downtrend.Set(elliot);


          }
          else
          {
          fastEma.Set(SMA(fast)[0]);
          slowEma.Set(SMA(slow)[0]);
          elliot = ((fastEma[0] - slowEma[0]));
          elliot3 = ((fastEma[3] - slowEma[3]));

          Value.Set(elliot);
          Elliott3.Set(elliot3);


          if (SMA(100)[0] > SMA(200)[0] && SMA(20)[0] > SMA(100)[0])
          Uptrend.Set(elliot);
          else if (SMA(100)[0] < SMA(200)[0] && SMA(20)[0] < SMA(100)[0])
          Downtrend.Set(elliot);
          else
          Neutral.Set(elliot);
          }


          }

          #region Properties
          /// <summary>
          /// </summary>
          [Browsable(false)]
          [XmlIgnore()]
          public DataSeries Default
          {
          get { return Values[0]; }
          }
          /// <summary>
          /// </summary>
          [Browsable(false)]
          [XmlIgnore()]
          public DataSeries Neutral
          {
          get { return Values[1]; }
          }
          [Browsable(false)]
          [XmlIgnore()]
          public DataSeries Uptrend
          {
          get { return Values[2]; }
          }

          [Browsable(false)]
          [XmlIgnore()]
          public DataSeries Downtrend
          {
          get { return Values[3]; }
          }

          /// <summary>
          /// </summary>
          [Browsable(false)]
          [XmlIgnore()]
          public DataSeries Elliott3
          {
          get { return Values[4]; }
          }




          /// <summary>
          /// </summary>
          [Description("Number of bars for fast SMA")]
          [Category("Parameters")]
          public int Fast
          {
          get { return fast; }
          set { fast = Math.Max(1, value); }
          }

          /// <summary>
          /// </summary>
          [Description("Number of bars for slow SMA")]
          [Category("Parameters")]
          public int Slow
          {
          get { return slow; }
          set { slow = Math.Max(1, value); }
          }

          #endregion
          }
          }

          #region NinjaScript generated code. Neither change nor remove.
          // This namespace holds all indicators and is required. Do not change it.
          namespace NinjaTrader.Indicator
          {
          public partial class Indicator : IndicatorBase
          {
          private ElliotOscillatorTEST[] cacheElliotOscillatorTEST = null;

          private static ElliotOscillatorTEST checkElliotOscillatorTEST = new ElliotOscillatorTEST();

          /// <summary>
          /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
          /// </summary>
          /// <returns></returns>
          public ElliotOscillatorTEST ElliotOscillatorTEST(int fast, int slow)
          {
          return ElliotOscillatorTEST(Input, fast, slow);
          }

          /// <summary>
          /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
          /// </summary>
          /// <returns></returns>
          public ElliotOscillatorTEST ElliotOscillatorTEST(Data.IDataSeries input, int fast, int slow)
          {
          if (cacheElliotOscillatorTEST != null)
          for (int idx = 0; idx < cacheElliotOscillatorTEST.Length; idx++)
          if (cacheElliotOscillatorTEST[idx].Fast == fast && cacheElliotOscillatorTEST[idx].Slow == slow && cacheElliotOscillatorTEST[idx].EqualsInput(input))
          return cacheElliotOscillatorTEST[idx];

          lock (checkElliotOscillatorTEST)
          {
          checkElliotOscillatorTEST.Fast = fast;
          fast = checkElliotOscillatorTEST.Fast;
          checkElliotOscillatorTEST.Slow = slow;
          slow = checkElliotOscillatorTEST.Slow;

          if (cacheElliotOscillatorTEST != null)
          for (int idx = 0; idx < cacheElliotOscillatorTEST.Length; idx++)
          if (cacheElliotOscillatorTEST[idx].Fast == fast && cacheElliotOscillatorTEST[idx].Slow == slow && cacheElliotOscillatorTEST[idx].EqualsInput(input))
          return cacheElliotOscillatorTEST[idx];

          ElliotOscillatorTEST indicator = new ElliotOscillatorTEST();
          indicator.BarsRequired = BarsRequired;
          indicator.CalculateOnBarClose = CalculateOnBarClose;
          #if NT7
          indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
          indicator.MaximumBarsLookBack = MaximumBarsLookBack;
          #endif
          indicator.Input = input;
          indicator.Fast = fast;
          indicator.Slow = slow;
          Indicators.Add(indicator);
          indicator.SetUp();

          ElliotOscillatorTEST[] tmp = new ElliotOscillatorTEST[cacheElliotOscillatorTEST == null ? 1 : cacheElliotOscillatorTEST.Length + 1];
          if (cacheElliotOscillatorTEST != null)
          cacheElliotOscillatorTEST.CopyTo(tmp, 0);
          tmp[tmp.Length - 1] = indicator;
          cacheElliotOscillatorTEST = tmp;
          return indicator;
          }
          }
          }
          }

          // This namespace holds all market analyzer column definitions and is required. Do not change it.
          namespace NinjaTrader.MarketAnalyzer
          {
          public partial class Column : ColumnBase
          {
          /// <summary>
          /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
          /// </summary>
          /// <returns></returns>
          [Gui.Design.WizardCondition("Indicator")]
          public Indicator.ElliotOscillatorTEST ElliotOscillatorTEST(int fast, int slow)
          {
          return _indicator.ElliotOscillatorTEST(Input, fast, slow);
          }

          /// <summary>
          /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
          /// </summary>
          /// <returns></returns>
          public Indicator.ElliotOscillatorTEST ElliotOscillatorTEST(Data.IDataSeries input, int fast, int slow)
          {
          return _indicator.ElliotOscillatorTEST(input, fast, slow);
          }
          }
          }

          // This namespace holds all strategies and is required. Do not change it.
          namespace NinjaTrader.Strategy
          {
          public partial class Strategy : StrategyBase
          {
          /// <summary>
          /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
          /// </summary>
          /// <returns></returns>
          [Gui.Design.WizardCondition("Indicator")]
          public Indicator.ElliotOscillatorTEST ElliotOscillatorTEST(int fast, int slow)
          {
          return _indicator.ElliotOscillatorTEST(Input, fast, slow);
          }

          /// <summary>
          /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
          /// </summary>
          /// <returns></returns>
          public Indicator.ElliotOscillatorTEST ElliotOscillatorTEST(Data.IDataSeries input, int fast, int slow)
          {
          if (InInitialize && input == null)
          throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

          return _indicator.ElliotOscillatorTEST(input, fast, slow);
          }
          }
          }
          #endregion

          Comment


            #6
            It should would, yes. As you would need to remove or comment out the section that previously was doing the plot assignment / coloring, namely this part -

            if (SMA(100)[0] > SMA(200)[0] && SMA(20)[0] > SMA(100)[0])
            Uptrend.Set(elliot);
            else if (SMA(100)[0] < SMA(200)[0] && SMA(20)[0] < SMA(100)[0])
            Downtrend.Set(elliot);
            else
            Neutral.Set(elliot);
            BertrandNinjaTrader Customer Service

            Comment


              #7
              here's what I have...the elliott wave does not show on the chart...i know in the colors its transparent but the uptrend and downtrend don't show...thanks

              //
              // Copyright (C) 2006, NinjaTrader LLC <[email protected]>.
              // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
              //

              #region Using declarations
              using System;
              using System.Diagnostics;
              using System.Drawing;
              using System.Drawing.Drawing2D;
              using System.ComponentModel;
              using System.Xml.Serialization;
              using NinjaTrader.Data;
              using NinjaTrader.Gui.Chart;
              #endregion

              // This namespace holds all indicators and is required. Do not change it.
              namespace NinjaTrader.Indicator
              {
              /// <summary>
              /// Elliot Oscillator
              /// </summary>
              [Description("The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.")]
              [Gui.Design.DisplayName("Elliot Oscillator")]
              public class EWOUpDn : Indicator
              {
              #region Variables
              private int fast = 5;
              private int slow = 34;
              private double elliot = 0;
              private double elliot3 = 0;
              private DataSeries fastEma;
              private DataSeries slowEma;
              #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.Transparent, "Elliot"));
              Add(new Plot(new Pen(Color.Black, 3), PlotStyle.Bar, "Neutral"));
              Add(new Plot(new Pen(Color.Blue, 3), PlotStyle.Bar, "UpTrend"));
              Add(new Plot(new Pen(Color.Red, 3), PlotStyle.Bar, "DownTrend"));
              Add(new Plot(Color.Red, "Elliot Displaced"));

              Add(new Line(Color.DarkGray, 0, "Zero line"));

              fastEma = new DataSeries(this);
              slowEma = new DataSeries(this);
              CalculateOnBarClose = true;
              PriceTypeSupported = true;
              AutoScale = true;
              }

              /// <summary>
              /// Calculates the indicator value(s) at the current index.
              /// </summary>
              protected override void OnBarUpdate()
              {
              if (CurrentBar < 3)
              return;
              if (CurrentBar == 0)
              {
              fastEma.Set(Input[0]);
              slowEma.Set(Input[0]);
              Value.Set(0);
              Elliott3.Set(0);


              if (Value[0] > 0)
              Uptrend.Set(elliot);
              else if (Value[0] < 0)
              Downtrend.Set(elliot);


              }
              else
              {
              fastEma.Set(SMA(fast)[0]);
              slowEma.Set(SMA(slow)[0]);
              elliot = ((fastEma[0] - slowEma[0]));
              elliot3 = ((fastEma[3] - slowEma[3]));

              Value.Set(elliot);
              Elliott3.Set(elliot3);


              if (SMA(100)[0] > SMA(200)[0] && SMA(20)[0] > SMA(100)[0])
              Uptrend.Set(elliot);
              else if (SMA(100)[0] < SMA(200)[0] && SMA(20)[0] < SMA(100)[0])
              Downtrend.Set(elliot);
              }


              }

              #region Properties
              /// <summary>
              /// </summary>
              [Browsable(false)]
              [XmlIgnore()]
              public DataSeries Default
              {
              get { return Values[0]; }
              }
              /// <summary>
              /// </summary>
              [Browsable(false)]
              [XmlIgnore()]
              public DataSeries Neutral
              {
              get { return Values[1]; }
              }
              [Browsable(false)]
              [XmlIgnore()]
              public DataSeries Uptrend
              {
              get { return Values[2]; }
              }

              [Browsable(false)]
              [XmlIgnore()]
              public DataSeries Downtrend
              {
              get { return Values[3]; }
              }

              /// <summary>
              /// </summary>
              [Browsable(false)]
              [XmlIgnore()]
              public DataSeries Elliott3
              {
              get { return Values[4]; }
              }




              /// <summary>
              /// </summary>
              [Description("Number of bars for fast SMA")]
              [Category("Parameters")]
              public int Fast
              {
              get { return fast; }
              set { fast = Math.Max(1, value); }
              }

              /// <summary>
              /// </summary>
              [Description("Number of bars for slow SMA")]
              [Category("Parameters")]
              public int Slow
              {
              get { return slow; }
              set { slow = Math.Max(1, value); }
              }

              #endregion
              }
              }

              #region NinjaScript generated code. Neither change nor remove.
              // This namespace holds all indicators and is required. Do not change it.
              namespace NinjaTrader.Indicator
              {
              public partial class Indicator : IndicatorBase
              {
              private EWOUpDn[] cacheEWOUpDn = null;

              private static EWOUpDn checkEWOUpDn = new EWOUpDn();

              /// <summary>
              /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
              /// </summary>
              /// <returns></returns>
              public EWOUpDn EWOUpDn(int fast, int slow)
              {
              return EWOUpDn(Input, fast, slow);
              }

              /// <summary>
              /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
              /// </summary>
              /// <returns></returns>
              public EWOUpDn EWOUpDn(Data.IDataSeries input, int fast, int slow)
              {
              if (cacheEWOUpDn != null)
              for (int idx = 0; idx < cacheEWOUpDn.Length; idx++)
              if (cacheEWOUpDn[idx].Fast == fast && cacheEWOUpDn[idx].Slow == slow && cacheEWOUpDn[idx].EqualsInput(input))
              return cacheEWOUpDn[idx];

              lock (checkEWOUpDn)
              {
              checkEWOUpDn.Fast = fast;
              fast = checkEWOUpDn.Fast;
              checkEWOUpDn.Slow = slow;
              slow = checkEWOUpDn.Slow;

              if (cacheEWOUpDn != null)
              for (int idx = 0; idx < cacheEWOUpDn.Length; idx++)
              if (cacheEWOUpDn[idx].Fast == fast && cacheEWOUpDn[idx].Slow == slow && cacheEWOUpDn[idx].EqualsInput(input))
              return cacheEWOUpDn[idx];

              EWOUpDn indicator = new EWOUpDn();
              indicator.BarsRequired = BarsRequired;
              indicator.CalculateOnBarClose = CalculateOnBarClose;
              #if NT7
              indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
              indicator.MaximumBarsLookBack = MaximumBarsLookBack;
              #endif
              indicator.Input = input;
              indicator.Fast = fast;
              indicator.Slow = slow;
              Indicators.Add(indicator);
              indicator.SetUp();

              EWOUpDn[] tmp = new EWOUpDn[cacheEWOUpDn == null ? 1 : cacheEWOUpDn.Length + 1];
              if (cacheEWOUpDn != null)
              cacheEWOUpDn.CopyTo(tmp, 0);
              tmp[tmp.Length - 1] = indicator;
              cacheEWOUpDn = tmp;
              return indicator;
              }
              }
              }
              }

              // This namespace holds all market analyzer column definitions and is required. Do not change it.
              namespace NinjaTrader.MarketAnalyzer
              {
              public partial class Column : ColumnBase
              {
              /// <summary>
              /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
              /// </summary>
              /// <returns></returns>
              [Gui.Design.WizardCondition("Indicator")]
              public Indicator.EWOUpDn EWOUpDn(int fast, int slow)
              {
              return _indicator.EWOUpDn(Input, fast, slow);
              }

              /// <summary>
              /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
              /// </summary>
              /// <returns></returns>
              public Indicator.EWOUpDn EWOUpDn(Data.IDataSeries input, int fast, int slow)
              {
              return _indicator.EWOUpDn(input, fast, slow);
              }
              }
              }

              // This namespace holds all strategies and is required. Do not change it.
              namespace NinjaTrader.Strategy
              {
              public partial class Strategy : StrategyBase
              {
              /// <summary>
              /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
              /// </summary>
              /// <returns></returns>
              [Gui.Design.WizardCondition("Indicator")]
              public Indicator.EWOUpDn EWOUpDn(int fast, int slow)
              {
              return _indicator.EWOUpDn(Input, fast, slow);
              }

              /// <summary>
              /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
              /// </summary>
              /// <returns></returns>
              public Indicator.EWOUpDn EWOUpDn(Data.IDataSeries input, int fast, int slow)
              {
              if (InInitialize && input == null)
              throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

              return _indicator.EWOUpDn(input, fast, slow);
              }
              }
              }
              #endregion

              Comment


                #8
                Hello thesoyboy2,

                I was able to chart this on my end without issue.

                Do you have any errors in the Log tab in the Control Center?

                Can you attach a screenshot of what you are seeing?
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  You mean you want nothing to be plotted if neutral would have been plotted?

                  Comment


                    #10


                    and I do have an error in the log:

                    Error on calling 'OnBarUpdate' method for indicator 'EWOUpDn' on bar 3: Index was outside the bounds of the array.

                    thanks

                    Comment


                      #11
                      Hello thesoyboy2,

                      Thank you for your response.

                      You lines of code stored in if(CurrentBar ==0) are never going to process as the preceding line ensures nothing processes below 3. I would change your code in the OnBarUpdate() to the following:
                      Code:
                      protected override void OnBarUpdate()
                      {
                      if (CurrentBar < 3)
                      return;
                      
                      fastEma.Set(Input[0]);
                      slowEma.Set(Input[0]);
                      Value.Set(0);
                      Elliott3.Set(0);
                      
                      fastEma.Set(SMA(fast)[0]);
                      slowEma.Set(SMA(slow)[0]);
                      elliot	 = ((fastEma[0] - slowEma[0]));
                      elliot3	 = ((fastEma[3] - slowEma[3]));
                      
                      Value.Set(elliot);
                      Elliott3.Set(elliot3);
                      
                      	if (Value[0] > 0)
                      Uptrend.Set(elliot);
                      else if (Value[0] < 0)
                      Downtrend.Set(elliot);
                      
                      }

                      Comment


                        #12
                        I copied what you have and it still doesn't work (no log errors)...thanks
                        C:\Users\brian\SkyDrive\Public\EWOaa.png

                        //
                        // Copyright (C) 2006, NinjaTrader LLC <[email protected]>.
                        // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
                        //

                        #region Using declarations
                        using System;
                        using System.Diagnostics;
                        using System.Drawing;
                        using System.Drawing.Drawing2D;
                        using System.ComponentModel;
                        using System.Xml.Serialization;
                        using NinjaTrader.Data;
                        using NinjaTrader.Gui.Chart;
                        #endregion

                        // This namespace holds all indicators and is required. Do not change it.
                        namespace NinjaTrader.Indicator
                        {
                        /// <summary>
                        /// Elliot Oscillator
                        /// </summary>
                        [Description("The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.")]
                        [Gui.Design.DisplayName("Elliot Oscillator")]
                        public class EWOaa : Indicator
                        {
                        #region Variables
                        private int fast = 5;
                        private int slow = 34;
                        private double elliot = 0;
                        private double elliot3 = 0;
                        private DataSeries fastEma;
                        private DataSeries slowEma;
                        #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.Transparent, "Elliot"));
                        Add(new Plot(new Pen(Color.Black, 3), PlotStyle.Bar, "Neutral"));
                        Add(new Plot(new Pen(Color.Blue, 3), PlotStyle.Bar, "UpTrend"));
                        Add(new Plot(new Pen(Color.Red, 3), PlotStyle.Bar, "DownTrend"));
                        Add(new Plot(Color.Red, "Elliot Displaced"));

                        Add(new Line(Color.DarkGray, 0, "Zero line"));

                        fastEma = new DataSeries(this);
                        slowEma = new DataSeries(this);
                        CalculateOnBarClose = true;
                        PriceTypeSupported = true;
                        AutoScale = true;
                        }

                        /// <summary>
                        /// Calculates the indicator value(s) at the current index.
                        /// </summary>
                        protected override void OnBarUpdate()
                        {
                        if (CurrentBar < 3)
                        return;

                        {
                        fastEma.Set(Input[0]);
                        slowEma.Set(Input[0]);
                        Value.Set(0);
                        Elliott3.Set(0);

                        fastEma.Set(SMA(fast)[0]);
                        slowEma.Set(SMA(slow)[0]);
                        elliot = ((fastEma[0] - slowEma[0]));
                        elliot3 = ((fastEma[3] - slowEma[3]));

                        Value.Set(elliot);
                        Elliott3.Set(elliot3);

                        if (Value[0] > 0)
                        Uptrend.Set(elliot);
                        else if (Value[0] < 0)
                        Downtrend.Set(elliot);


                        }



                        }

                        #region Properties
                        /// <summary>
                        /// </summary>
                        [Browsable(false)]
                        [XmlIgnore()]
                        public DataSeries Default
                        {
                        get { return Values[0]; }
                        }
                        /// <summary>
                        /// </summary>
                        [Browsable(false)]
                        [XmlIgnore()]
                        public DataSeries Neutral
                        {
                        get { return Values[1]; }
                        }
                        [Browsable(false)]
                        [XmlIgnore()]
                        public DataSeries Uptrend
                        {
                        get { return Values[2]; }
                        }

                        [Browsable(false)]
                        [XmlIgnore()]
                        public DataSeries Downtrend
                        {
                        get { return Values[3]; }
                        }

                        /// <summary>
                        /// </summary>
                        [Browsable(false)]
                        [XmlIgnore()]
                        public DataSeries Elliott3
                        {
                        get { return Values[4]; }
                        }




                        /// <summary>
                        /// </summary>
                        [Description("Number of bars for fast SMA")]
                        [Category("Parameters")]
                        public int Fast
                        {
                        get { return fast; }
                        set { fast = Math.Max(1, value); }
                        }

                        /// <summary>
                        /// </summary>
                        [Description("Number of bars for slow SMA")]
                        [Category("Parameters")]
                        public int Slow
                        {
                        get { return slow; }
                        set { slow = Math.Max(1, value); }
                        }

                        #endregion
                        }
                        }

                        #region NinjaScript generated code. Neither change nor remove.
                        // This namespace holds all indicators and is required. Do not change it.
                        namespace NinjaTrader.Indicator
                        {
                        public partial class Indicator : IndicatorBase
                        {
                        private EWOaa[] cacheEWOaa = null;

                        private static EWOaa checkEWOaa = new EWOaa();

                        /// <summary>
                        /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
                        /// </summary>
                        /// <returns></returns>
                        public EWOaa EWOaa(int fast, int slow)
                        {
                        return EWOaa(Input, fast, slow);
                        }

                        /// <summary>
                        /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
                        /// </summary>
                        /// <returns></returns>
                        public EWOaa EWOaa(Data.IDataSeries input, int fast, int slow)
                        {
                        if (cacheEWOaa != null)
                        for (int idx = 0; idx < cacheEWOaa.Length; idx++)
                        if (cacheEWOaa[idx].Fast == fast && cacheEWOaa[idx].Slow == slow && cacheEWOaa[idx].EqualsInput(input))
                        return cacheEWOaa[idx];

                        lock (checkEWOaa)
                        {
                        checkEWOaa.Fast = fast;
                        fast = checkEWOaa.Fast;
                        checkEWOaa.Slow = slow;
                        slow = checkEWOaa.Slow;

                        if (cacheEWOaa != null)
                        for (int idx = 0; idx < cacheEWOaa.Length; idx++)
                        if (cacheEWOaa[idx].Fast == fast && cacheEWOaa[idx].Slow == slow && cacheEWOaa[idx].EqualsInput(input))
                        return cacheEWOaa[idx];

                        EWOaa indicator = new EWOaa();
                        indicator.BarsRequired = BarsRequired;
                        indicator.CalculateOnBarClose = CalculateOnBarClose;
                        #if NT7
                        indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                        indicator.MaximumBarsLookBack = MaximumBarsLookBack;
                        #endif
                        indicator.Input = input;
                        indicator.Fast = fast;
                        indicator.Slow = slow;
                        Indicators.Add(indicator);
                        indicator.SetUp();

                        EWOaa[] tmp = new EWOaa[cacheEWOaa == null ? 1 : cacheEWOaa.Length + 1];
                        if (cacheEWOaa != null)
                        cacheEWOaa.CopyTo(tmp, 0);
                        tmp[tmp.Length - 1] = indicator;
                        cacheEWOaa = tmp;
                        return indicator;
                        }
                        }
                        }
                        }

                        // This namespace holds all market analyzer column definitions and is required. Do not change it.
                        namespace NinjaTrader.MarketAnalyzer
                        {
                        public partial class Column : ColumnBase
                        {
                        /// <summary>
                        /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
                        /// </summary>
                        /// <returns></returns>
                        [Gui.Design.WizardCondition("Indicator")]
                        public Indicator.EWOaa EWOaa(int fast, int slow)
                        {
                        return _indicator.EWOaa(Input, fast, slow);
                        }

                        /// <summary>
                        /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
                        /// </summary>
                        /// <returns></returns>
                        public Indicator.EWOaa EWOaa(Data.IDataSeries input, int fast, int slow)
                        {
                        return _indicator.EWOaa(input, fast, slow);
                        }
                        }
                        }

                        // This namespace holds all strategies and is required. Do not change it.
                        namespace NinjaTrader.Strategy
                        {
                        public partial class Strategy : StrategyBase
                        {
                        /// <summary>
                        /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
                        /// </summary>
                        /// <returns></returns>
                        [Gui.Design.WizardCondition("Indicator")]
                        public Indicator.EWOaa EWOaa(int fast, int slow)
                        {
                        return _indicator.EWOaa(Input, fast, slow);
                        }

                        /// <summary>
                        /// The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.
                        /// </summary>
                        /// <returns></returns>
                        public Indicator.EWOaa EWOaa(Data.IDataSeries input, int fast, int slow)
                        {
                        if (InInitialize && input == null)
                        throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

                        return _indicator.EWOaa(input, fast, slow);
                        }
                        }
                        }
                        #endregion

                        Comment


                          #13
                          Please give the attached a try, I think it should visualize what you seeked.
                          Attached Files
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            thanks. here's a screen shot of what i got.
                            C:\Users\brian\SkyDrive\Public\cs_file_ninja.png

                            One thing is neutral is there...just transparent
                            The other thing is that what I would like is one color if oscillator is above zero line and one color if it is below zero line...this is still using uptrend and downtrend

                            thank you so much for all your help...

                            Comment


                              #15
                              Correct my apologies, there was the neutral series still defined in the properties of the indicator actually so you could run into an array issue as you had seen, the version attached will fix that. For the coloring this will use the two plots, however you may also switch colors over using NT7's PlotColors approach -

                              Attached Files
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by funk10101, Today, 12:02 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post funk10101  
                              Started by gravdigaz6, Yesterday, 11:40 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by MarianApalaghiei, Yesterday, 10:49 PM
                              3 responses
                              10 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by XXtrader, Yesterday, 11:30 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post XXtrader  
                              Started by love2code2trade, 04-17-2024, 01:45 PM
                              4 responses
                              28 views
                              0 likes
                              Last Post love2code2trade  
                              Working...
                              X