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

hide the parameters of an ocsilator.

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

    hide the parameters of an ocsilator.

    for example the values ​​of the slow sma two values ​​one 15 and 20 that cannot be changed but choose from a drop-down list .. someone help me
    Attached Files

    #2
    Hello TraderElegante,

    Thank you for your post.

    To clarify, are you saying you want to basically hardcode a list of values for the EMA in a dropdown that you can choose from to have predefined fast and slow? Something like a dropdown list with say, 15 & 20 being one option and maybe other options like 10 & 25 that you could just choose that would then use those chosen values for the Oscillator? Is that correct? If not, can you further clarify the modifications you're wanting to see?

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      that's right

      Comment


        #4
        Hello TraderElegante,

        Thank you for your reply.

        You'd need to modify a few things here. I'm putting some example modifications in the script below, but basically you would need to comment out the current user inputs for fast and slow, and define those at the top of the script instead. You'd also want to remove the defaults from these from State.SetDefaults.

        You'd also want to make an enum for the user to select an option, then assign values for fast and slow based on that selection.

        Please see the sample changes along with my comments in the script below:

        Code:
        //This namespace holds Indicators in this folder and is required. Do not change it.
        namespace NinjaTrader.NinjaScript.Indicators
        {
        public class ElliotOscillator : Indicator
        {
        private Series<double> fastEMA;
        private Series<double> slowEMA;
        private double elliot = 0;
        private double elliot3 = 0;
        
        [B]// define fast and slow up here, we will assign these based on the enum selected by the user
        private int Fast;
        private int Slow;
        
        // add internal variable that we will expose below to hold our enum value
        private CustomPeriodSettings.PeriodSettings myPeriodSetting;[/B]
        
        protected override void OnStateChange()
        {
        if (State == State.SetDefaults)
        {
        Description = @"The Elliot Oscillator is a trend following momentum indicator that shows the relationship between two moving averages of prices.";
        Name = "ElliotOscillator";
        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;
        
        [B]// default values for fast and slow removed
        // set default for the enum selection
        myPeriodSetting = CustomPeriodSettings.PeriodSettings.Fast15Slow20;[/B]
        
        AddPlot(new Stroke(Brushes.Black, 2), PlotStyle.Bar, "Neutral");
        AddPlot(new Stroke(Brushes.Blue, 2), PlotStyle.Bar, "UpTrend");
        AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Bar, "DownTrend");
        AddPlot(new Stroke(Brushes.Transparent, 2), PlotStyle.Line, "Elliot");
        AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Line, "Elliot Displaced");
        
        }
        else if (State == State.Configure)
        {
        [B]// assign fast and slow based on the enum value selected
        switch (MyPeriodSetting)
        {
        case CustomPeriodSettings.PeriodSettings.Fast15Slow20:
        {
        Fast = 15;
        Slow = 20;
        break;
        }
        case CustomPeriodSettings.PeriodSettings.Fast5Slow10:
        {
        Fast = 5;
        Slow = 10;
        break;
        }
        case CustomPeriodSettings.PeriodSettings.Fast10Slow15:
        {
        Fast = 10;
        Slow = 15;
        break;
        }
        }[/B]
        }
        else if (State == State.DataLoaded)
        {
        fastEMA = new Series<double>(this);
        slowEMA = new Series<double>(this);
        }
        }
        
        protected override void OnBarUpdate()
        {
        if (CurrentBar < 3)
        return;
        if (CurrentBar == 0)
        {
        fastEMA[0] = (Input[0]);
        slowEMA[0] = (Input[0]);
        Value[0] = (0);
        Elliott3[0] = (0);
        
        
        if (SMA(100)[0] > SMA(200)[0] && SMA(20)[0] > SMA(100)[0])
        UpTrend[0] = (0);
        else if (SMA(100)[0] < SMA(200)[0] && SMA(20)[0] < SMA(100)[0])
        DownTrend[0] = 0;
        else
        Neutral[0] = (0);
        }
        else
        {
        fastEMA[0] = (SMA(Fast)[0]);
        slowEMA[0] = (SMA(Slow)[0]);
        elliot = ((fastEMA[0] - slowEMA[0]));
        elliot3 = ((fastEMA[3] - slowEMA[3]));
        
        Value[0] = elliot;
        Elliott3[0] = elliot3;
        
        
        if (SMA(100)[0] > SMA(200)[0] && SMA(20)[0] > SMA(100)[0])
        UpTrend[0] = (elliot);
        else if (SMA(100)[0] < SMA(200)[0] && SMA(20)[0] < SMA(100)[0])
        DownTrend[0] = (elliot);
        else
        Neutral[0] = (elliot);
        }
        }
        
        #region Properties
        [B]// remove the user inputs for Fast and Slow - we have defined them as regular variables at the top[/B]
        
        [B]// add a property so our enum values are displayed and the user can choose between them
        [NinjaScriptProperty]
        [Display(Name=@"Fast/Slow Setting", GroupName = "Parameters", Description="Choose a Fast/Slow Combination")]
        public CustomPeriodSettings.PeriodSettings MyPeriodSetting
        {
        get { return myPeriodSetting; }
        set { myPeriodSetting = value; }
        }[/B]
        
        [Browsable(false)]
        [XmlIgnore()]
        public Series<double> Default
        {
        get { return Values[0]; }
        }
        
        [Browsable(false)]
        [XmlIgnore]
        public Series<double> Neutral
        {
        get { return Values[1]; }
        }
        
        [Browsable(false)]
        [XmlIgnore]
        public Series<double> UpTrend
        {
        get { return Values[2]; }
        }
        
        [Browsable(false)]
        [XmlIgnore]
        public Series<double> DownTrend
        {
        get { return Values[3]; }
        }
        
        [Browsable(false)]
        [XmlIgnore()]
        public Series<double> Elliott3
        {
        get { return Values[4]; }
        }
        #endregion
        
        }
        }
        [B]// enum for the selections, you can only choose from these, you can add additional ones to the enum if you like
        namespace CustomPeriodSettings
        {
        public enum PeriodSettings
        {
        Fast5Slow10,
        Fast10Slow15,
        Fast15Slow20
        }
        }[/B]
        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          [QUOTE = NinjaTrader_Kate; n1175472] Hola, TraderElegante,

          Gracias por su respuesta.

          Debería modificar algunas cosas aquí. Estoy poniendo algunas modificaciones de ejemplo en el script a continuación, pero básicamente necesitaría comentar las entradas del usuario actual para rápido y lento, y definirlas en la parte superior del script en su lugar. También querrá eliminar los valores predeterminados de estos de State.SetDefaults.

          También querrá hacer una enumeración para que el usuario seleccione una opción, luego asigne valores para rápido y lento en función de esa selección.

          Consulte los cambios de muestra junto con mis comentarios en el siguiente script:

          [CÓDIGO] // Este espacio de nombres contiene Indicadores en esta carpeta y es obligatorio. No lo cambie.
          espacio de nombres NinjaTrader.NinjaScript.Indicators
          {
          public class ElliotOscillator: Indicator
          {
          Private Series <double> fastEMA;
          Serie privada <doble> slowEMA;
          elliot doble privado = 0;
          privado doble elliot3 = 0;

          // define rápido y lento aquí, los asignaremos en función de la enumeración seleccionada por el usuario
          private int Fast;
          privado int lento;

          // agregamos la variable interna que
          expondremos a continuación para mantener nuestro valor de enumeración privado CustomPeriodSettings.PeriodSettings myPeriodSetting;


          protected override void OnStateChange ()
          {
          if (State == State.SetDefaults)
          {
          Description = @ "El oscilador de Elliot es una tendencia que sigue el indicador de impulso que muestra la relación entre dos promedios móviles de precios.";
          Nombre = "ElliotOscillator";
          Calcular = Calcular.OnBarClose;
          IsOverlay = falso;
          DisplayInDataBox = verdadero;
          DrawOnPricePanel = true;
          DrawHorizontalGridLines = true;
          DrawVerticalGridLines = true;
          PaintPriceMarkers = verdadero;
          ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
          // Desactive esta propiedad si su indicador requiere valores personalizados que se acumulan con cada nuevo evento de datos de mercado.
          // Consulte la Guía de ayuda para obtener información adicional.
          IsSuspendedWhileInactive = true;

          // valores predeterminados para eliminación rápida y lenta
          // establecer valores predeterminados para la selección de enumeración
          myPeriodSetting = CustomPeriodSettings.PeriodSettings.Fast15Slow20;


          AddPlot (nuevo Stroke (Brushes.Black, 2), PlotStyle.Bar, "Neutral");
          AddPlot (nuevo Stroke (Brushes.Blue, 2), PlotStyle.Bar, "UpTrend");
          AddPlot (nuevo Stroke (Brushes.Red, 2), PlotStyle.Bar, "DownTrend");
          AddPlot (nuevo Stroke (Brushes.Transparent, 2), PlotStyle.Line, "Elliot");
          AddPlot (nuevo trazo (Brushes.Red, 2), PlotStyle.Line, "Elliot desplazado");

          }
          else if (State == State.Configure)
          {
          // asignar rápido y lento basado en el valor de enumeración seleccionado
          switch (MyPeriodSetting)
          {
          case CustomPeriodSettings.PeriodSettings.Fast15Slow20:
          {
          Fast = 15;
          Lento = 20;
          rotura;
          }
          case CustomPeriodSettings.PeriodSettings.Fast5Slow10:


          Lento = 10;
          rotura;
          }
          case CustomPeriodSettings.PeriodSettings.Fast10Slow15:
          {
          Fast = 10;
          Lento = 15;
          rotura;
          }
          }

          }
          else if (State == State.DataLoaded)
          {
          fastEMA = new Series <doble> (esto);
          slowEMA = nueva serie <doble> (este);
          }
          }

          anulación protegida void OnBarUpdate ()
          {
          if (CurrentBar <3)
          return;
          if (CurrentBar == 0)
          {
          fastEMA [0] = (Entrada [0]);
          slowEMA [0] = (Entrada [0]);
          Valor [0] = (0);
          Elliott3 [0] = (0);


          si (SMA (100) [0]> SMA (200) [0] && SMA (20) [0]> SMA (100) [0])
          UpTrend [0] = (0);
          de lo contrario, si (SMA (100) [0] <SMA (200) [0] && SMA (20) [0] <SMA (100) [0])
          Tendencia a la baja [0] = 0;
          si no
          Neutral [0] = (0);
          }
          más
          {
          fastEMA [0] = (SMA (Rápido) [0]);
          slowEMA [0] = (SMA (lento) [0]);
          elliot = ((fastEMA [0] - slowEMA [0]));
          elliot3 = ((fastEMA [3] - slowEMA [3]));

          Valor [0] = elliot;
          Elliott3 [0] = elliot3;


          si (SMA (100) [0]> SMA (200) [0] && SMA (20) [0]> SMA (100) [0])
          UpTrend [0] = (elliot);
          de lo contrario, si (SMA (100) [0] <SMA (200) [0] && SMA (20) [0] <SMA (100) [0])
          Tendencia a la baja [0] = (elliot);
          más
          Neutral [0] = (elliot);
          }
          }

          #region Properties
          // eliminar las entradas del usuario para Fast y Slow: las hemos definido como variables regulares en la parte superior

          // agregar una propiedad para que se muestren nuestros valores de enumeración y el usuario pueda elegir entre ellos
          [NinjaScriptProperty]
          [Display (Name = @ "Fast / Configuración lenta ", GroupName =" Parámetros ", Descripción =" Elija una combinación rápida / lenta ")]
          public CustomPeriodSettings.PeriodSettings MyPeriodSetting
          {
          get {return myPeriodSetting; }
          establecer {myPeriodSetting = valor; }
          }


          [Navegable (falso)]
          [XmlIgnore ()]
          public Series <double> Predeterminado
          {
          get {return Values ​​[0]; }
          }

          [Navegable (falso)]
          [XmlIgnore]
          public Series <double> Neutral
          {
          get {return Values ​​[1]; }
          }

          [Navegable (falso)]
          [XmlIgnore]
          public Series <double> UpTrend
          {
          get {return Values ​​[2]; }
          }

          [Navegable (falso)]
          [XmlIgnore]
          public Series <double> DownTrend
          {
          get {return Values ​​[3]; }
          }

          [Navegable (falso)]
          [XmlIgnore ()]
          public Series <double> Elliott3
          {
          get {return Values ​​[4]; }
          }
          #endregion

          }
          }
          // enumeración para las selecciones, solo puede elegir entre estas, puede agregar otras adicionales a la enumeración si le gusta el
          espacio de nombres CustomPeriodSettings
          {
          public enum PeriodSettings
          {
          Fast5Slow10,
          Fast10Slow15,
          Fast15Slow20
          }
          }
          [/ CODE]

          // define rápido y lento aquí, los asignaremos en función de la enumeración seleccionada por el usuario
          private int Fast;
          privado int lento;

          // agregamos la variable interna que expondremos a continuación para mantener nuestro valor de enumeración
          private CustomPeriodSettings.PeriodSettings myPeriodSetting;

          protected override void OnStateChange ()
          {
          if (State == State.SetDefaults)
          {
          Description = @ "El oscilador de Elliot es una tendencia que sigue el indicador de impulso que muestra la relación entre dos promedios móviles de precios.";
          Nombre = "1ElliotOscillator";
          Calcular = Calcular.OnBarClose;
          IsOverlay = falso;
          DisplayInDataBox = verdadero;
          DrawOnPricePanel = true;
          DrawHorizontalGridLines = true;
          DrawVerticalGridLines = true;
          PaintPriceMarkers = verdadero;
          ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
          // Desactive esta propiedad si su indicador requiere valores personalizados que se acumulan con cada nuevo evento de datos de mercado.
          // Consulte la Guía de ayuda para obtener información adicional.
          IsSuspendedWhileInactive = true;
          // Rápido = 5;
          // Lento = 35;

          // valores predeterminados para eliminación rápida y lenta
          // establecer valores predeterminados para la selección de enumeración
          myPeriodSetting = CustomPeriodSettings.PeriodSettings.Fast15Slow20;

          AddPlot (nuevo Stroke (Brushes.Green, 2), PlotStyle.Bar, "OscAGUpr");
          AddPlot (nuevo trazo (Brushes.Red, 2), PlotStyle.Bar, "OscAGLwr");


          }
          else if (State == State.Configure)
          {// asignar rápido y lento en función del valor de enumeración seleccionado el
          interruptor (MyPeriodSetting)
          {
          case CustomPeriodSettings.PeriodSettings.Fast15Slow20:
          {
          Fast = 15;
          Lento = 20;
          rotura;
          }
          case CustomPeriodSettings.PeriodSettings.Fast5Slow10:
          {
          Fast = 5;
          Lento = 10;
          rotura;
          }
          case CustomPeriodSettings.PeriodSettings.Fast10Slow15:
          {
          Fast = 10;
          Lento = 15;
          rotura;
          }
          }

          }
          Last edited by TraderElegante; 10-22-2021, 12:43 PM.

          Comment


            #6
            Hello TraderElegante,

            Thank you for your reply.

            I note you've removed where the two FastEMA and SlowEMA series are declared at the top as these are missing from your version:


            private Series<double> fastEMA;
            private Series<double> slowEMA;

            However, you didn't remove where they were actually assigned as a series in State.DataLoaded:

            else if (State == State.DataLoaded)
            {
            fastEMA = new Series<double>(this);
            slowEMA = new Series<double>(this);
            }

            If you remove the references there are you able to compile?

            Thanks in advance; I look forward to assisting you further.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Kate View Post
              Hello TraderElegante,

              Thank you for your reply.

              I note you've removed where the two FastEMA and SlowEMA series are declared at the top as these are missing from your version:


              private Series<double> fastEMA;
              private Series<double> slowEMA;

              However, you didn't remove where they were actually assigned as a series in State.DataLoaded:

              else if (State == State.DataLoaded)
              {
              fastEMA = new Series<double>(this);
              slowEMA = new Series<double>(this);
              }

              If you remove the references there are you able to compile?

              Thanks in advance; I look forward to assisting you further.
              if i delete .. i get this message: cannot find type or namespace name "customPeriodSettings' (missing using directive or assembly reference?)

              Comment


                #8
                Originally posted by NinjaTrader_Kate View Post
                Hello TraderElegante,

                Thank you for your reply.

                I note you've removed where the two FastEMA and SlowEMA series are declared at the top as these are missing from your version:


                private Series<double> fastEMA;
                private Series<double> slowEMA;

                However, you didn't remove where they were actually assigned as a series in State.DataLoaded:

                else if (State == State.DataLoaded)
                {
                fastEMA = new Series<double>(this);
                slowEMA = new Series<double>(this);
                }

                If you remove the references there are you able to compile?

                Thanks in advance; I look forward to assisting you further.
                I already solved it thanks for your help

                Comment


                  #9
                  a query to calculate a value of a certain bar and draw a dotted line is very complex?

                  Comment


                    #10
                    Hello TraderElegante,

                    Thank you for your reply.

                    I don't understand your question "a query to calculate a value of a certain bar and draw a dotted line is very complex?" - can you clarify?

                    Thanks in advance; I look forward to assisting you further.
                    Kate W.NinjaTrader Customer Service

                    Comment


                      #11
                      [QUOTE = NinjaTrader_Kate; n1175574] Hola, TraderElegante,

                      Gracias por su respuesta.

                      No entiendo su pregunta "żuna consulta para calcular el valor de una determinada barra y dibujar una línea de puntos es muy compleja?" - żpuedes aclarar?

                      Gracias por adelantado; Espero poder ayudarlo más. [/ QUOTE]


                      es tomar el valor de la primera vela cuando la tendencia es bajista (velas rojas) o cuando es alcista (velas azules) calcular (Alto [0] + ((Alto [0] - Bajo [0]) * 1.0) ) y que genera el stop y (Alto [0] - ((Alto [0] + Bajo [0]) * 1.0)) genera la entrada que serían las dos líneas punteadas como se ve en la imagen .. el rojo uno y azul .. no sé si me hice entender ahora?
                      Last edited by TraderElegante; 10-21-2021, 12:03 PM.

                      Comment


                        #12
                        Hello TraderElegante,

                        Thank you for your reply.

                        Am I understanding correctly that you're wanting to draw dots at specific prices above and below the High of the first bar to be that color plus or minus the range of the bar?

                        I would recommend using a Series to track when the trend changes rather than a regular variable so you can check the trend value of the previous bar.

                        Once you've determined the trend value for the current bar, you can then check whether it was the same on the previous bar or not, and if it has changed, assign values to your Stop/Entry/Target plots. Then, if you check and the trend is the same on the current bar as the prior one, assign the previous value of the plot to the current value to continue to plot at the same price.

                        I'm attaching a modified version of the indicator that demonstrates, with comments explaining the logic.

                        Please let us know if we may be of further assistance to you.
                        Attached Files
                        Kate W.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_Kate View Post
                          Hello TraderElegante,

                          Thank you for your reply.

                          Am I understanding correctly that you're wanting to draw dots at specific prices above and below the High of the first bar to be that color plus or minus the range of the bar?

                          I would recommend using a Series to track when the trend changes rather than a regular variable so you can check the trend value of the previous bar.

                          Once you've determined the trend value for the current bar, you can then check whether it was the same on the previous bar or not, and if it has changed, assign values to your Stop/Entry/Target plots. Then, if you check and the trend is the same on the current bar as the prior one, assign the previous value of the plot to the current value to continue to plot at the same price.

                          I'm attaching a modified version of the indicator that demonstrates, with comments explaining the logic.

                          Please let us know if we may be of further assistance to you.
                          It works perfect .. the only thing would be that when the trend is bullish, the stop is red below ... and the target would be double the stop .. when a bar touches entry, stop drawing the entry and start drawing the target. the same bullish and bearish way ..

                          Comment


                            #14
                            Hello TraderElegante,

                            Thank you for your reply.

                            We in the support department cannot write your logic for you, only give examples to put you down the correct path. The example provided shows how you can basically do those calculations and assign them to plots by checking prior bars, we would expect that you would build off the example given to create your own logic.

                            If you are interested in services in having the code written for you, I can have a representative of our EcoSystem reach out with more information on NinjaScript consultants who will be happy to do so.

                            Please let us know if we may be of further assistance to you.
                            Kate W.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_Kate View Post
                              Hello TraderElegante,

                              Thank you for your reply.

                              We in the support department cannot write your logic for you, only give examples to put you down the correct path. The example provided shows how you can basically do those calculations and assign them to plots by checking prior bars, we would expect that you would build off the example given to create your own logic.

                              If you are interested in services in having the code written for you, I can have a representative of our EcoSystem reach out with more information on NinjaScript consultants who will be happy to do so.

                              Please let us know if we may be of further assistance to you.
                              if I solve the colors .. do you have a simple example ?? to see how it works if the current candle is higher a line stop drawing and draw a dot line as well as for the low or bullish .. thanks

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Mikey_, 03-23-2024, 05:59 PM
                              3 responses
                              48 views
                              0 likes
                              Last Post Sam2515
                              by Sam2515
                               
                              Started by f.saeidi, Today, 12:14 PM
                              7 responses
                              16 views
                              0 likes
                              Last Post f.saeidi  
                              Started by Russ Moreland, Today, 12:54 PM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by philmg, Today, 12:55 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_ChristopherJ  
                              Started by TradeForge, 04-19-2024, 02:09 AM
                              2 responses
                              32 views
                              0 likes
                              Last Post TradeForge  
                              Working...
                              X