Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Hel in Understanding error in Indicator

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

    Hel in Understanding error in Indicator

    I'm at the beginning of modifying an indicator that involves 2 data series - D & K - which will be plotted at the bottom of a price chart. I get the same error for lines 113 and 125 (properties region) of the code This is something simple, but I'm missing it. Still learning to code using NS8, so any help would be welcomed.

    ERROR: Using a generic type 'NinjaTrader.NinjaScript.Series<T>' requires 1 type arguments
    The error is not explained in the manual.

    I know I'm doing something wrong syntaxwise, but I'm also not sure how to frame the properties for D and K so that I can plot them


    Thanks in advance.

    D

    Code:
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion
    
    //This namespace holds indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
        /*
                The StoRSI is an oscillator similar in computation to the stochastic measure,
                except instead of price values as input, the StoRSI uses RSI values.
                The StoRSI computes the current position of the RSI relative to the high and
                low RSI values over a specified number of days. The intent of this measure,
                designed by Tushard Chande and Stanley Kroll, is to provide further information
                about the overbought/oversold nature of the RSI. The StoRSI ranges between 0.0 and 1.0.
                Values above 0.8 are generally seen to identify overbought levels and values below 0.2 are
                considered to indicate oversold conditions.
        */
    
    
        public class Lynx_StoRSI : Indicator
        {    
            private MAX max;
            private MIN min;
            private RSI rsi;
    
            public Series<double> D;
            public Series<double> K;
    
            #region Variables
            private int            periodRSI    = 13;
            private int            periodD        = 13;
            private int            periodK        = 8;
            #endregion
    
            public override string DisplayName
            {                
            get { return "Lynx Stochastic RSI"; } ///PREVENTS SHOWING ALL PARAMETERS AT THE TOP OF THE INDICATOR
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>            
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"The Lynx StoRSI is an oscillator similar in computation to the stochastic measure, except instead of price values as input, the LynxStoRSI uses RSI values. The LynxStoRSI computes the current position of the RSI relative to the high and low RSI values over a specified number of days. The intent of this measure, designed by Tushard Chande and Stanley Kroll, is to provide further information about the overbought/oversold nature of the RSI. The LynxStoRSI ranges between 0.0 and 1.0. Values above 0.8 are generally seen to identify overbought levels and values below 0.2 are considered to indicate oversold conditions.";
                    Name                                        = "Lynx Stochastic RSI";
                    IsSuspendedWhileInactive                    = true;
                    Calculate                                    = Calculate.OnBarClose;
                    IsOverlay                                    = false;
                    DisplayInDataBox                            = true;
                    DrawOnPricePanel                            = false;
                    DrawHorizontalGridLines                        = true;
                    DrawVerticalGridLines                        = true;
                    PaintPriceMarkers                            = true;
                    ScaleJustification                            = NinjaTrader.Gui.Chart.ScaleJustification.Right;        
    
                    AddPlot(Brushes.Red, "D");
                    AddPlot(Brushes.Cyan, "K");
    
                    AddLine(Brushes.Red,  0.8, "Overbought");
                    AddLine(Brushes.Blue, 0.5, "Neutral");
                    AddLine(Brushes.Red,  0.2, "Oversold");
                }    
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>    
    
                else if (State == State.DataLoaded)
                {
                    rsi     = RSI(Inputs[0], PeriodRSI, 1)[0];
                    rsiL    = MIN(RSI(Inputs[0], PeriodRSI, 1), PeriodD[0]);
                    rsiH     = MAX(RSI(Inputs[0], PeriodRSI, 1), PeriodD[0]);
    
                    if (rsi != rsiL && rsiH != rsiL)
                        K.Set((rsi - rsiL) / (rsiH - rsiL));
                    else
                        K.Set(0);
                        D.Set(SMA(K, PeriodK)[0]);                
                }                    
            }
    
            //-----------------------------------
    
            #region Properties
            /// <summary>
            /// Gets the slow D value.
            /// </summary>
            [Browsable(false)]
            [XmlIgnore()]
            public Series D
            {
                get { return Values[0]; }
            }
    
            //-----------------------------------
    
            /// <summary>
            /// Gets the slow K value.
            /// </summary>
            [Browsable(false)]
            [XmlIgnore()]
            public Series K
            {
                get { return Values[1]; }
            }
    
            //-----------------------------------        
    
            /// <summary>
            /// </summary>
            [Description("Numbers of bars used for moving average over K values")]
            [Display(Name = "Period for RSI", Order = 1, GroupName = "My Parameters")]
            int PeriodRSI
            {
                get { return periodRSI; }
                set { periodRSI = Math.Max(1, value); }
            }
    
            //-----------------------------------        
    
            /// <summary>
            /// </summary>
            [Description("Numbers of bars used for moving average over K values")]
            [Display(Name = "Period for D", Order = 1, GroupName = "My Parameters")]
            public int PeriodD
            {
                get { return periodD; }
                set { periodD = Math.Max(1, value); }
            }
    
            //-----------------------------------        
    
            /// <summary>
            /// </summary>
            [Description("Numbers of bars used for calculating the K values")]
            [Display(Name = "Period for K", Order = 1, GroupName = "My Parameters")]
            public int PeriodK
            {
                get { return periodK; }
                set { periodK = Math.Max(1, value); }
            }
    
            #endregion
        }
    }

    #2
    Hello dmking,

    Thanks for your post.

    It looks like you are defining "D" and "K" as a public series in both region properties and at the class level. The D & K in region properties are associated with the added plots of D & K which is needed.

    I recommend removing or commenting out these lines:
    public Series<double> D;
    public Series<double> K;

    Comment


      #3
      Thanks Paul,

      Yeah, I saw that and commented those lines out before I sent the post. I sent you the code with those line still in - sorry about any confusion that caused. So, after commenting out the two lines I get:
      ERROR: Using a generic type 'NinjaTrader.NinjaScript.Series<T>' requires 1 type arguments
      The error is not explained in the manual.

      Any suggestions?

      D

      Comment


        #4
        Hello dmking,

        Thanks for your reply.

        On a second look, I see that you must be converting this from NT7.

        In NT7 you would use the .Set() to provide the value to plot. In NT8 you would change that to [0] =.

        For example, from K.Set(0); to K[0] = 0;

        Comment


          #5
          Paul, Thanks for taking the time to help me out. I'm stumbling on the idea of the Series and how it's handled in NS8, In NT7 you could declare "public DataSeries D". However if I take this notion over to NS8 and write:

          Code:
                  #region Properties
                  /// <summary>
                  /// Gets the slow D value.
                  /// </summary>
                  [Browsable(false)]
                  [XmlIgnore()]
                  Series D
                  {
                      get { return Values[0]; }
                  }
          I looked at - https://ninjatrader.com/support/help...s/?seriest.htm - but I'm missing something.

          TIA
          D

          Comment


            #6
            Hello dmking,

            Thanks for your reply.

            Your example shows Series D.
            It should show as public Series<double> D

            A great way to see how this should look is to use the Ninjascript indicator wizard (click on the "+" tab in the ninjascript editor, lower left) and select "new indicator" , add some inputs and a plot or two, then generate the script and that will show you the formatting. This is the process I would follow if converting from NT7 to NT8 as it ensures you have all the NT8 structural pieces in place. Reference: https://ninjatrader.com/support/help...?ns_wizard.htm

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            637 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            366 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            107 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            569 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            572 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X