Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

member name error

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

    member name error

    Hi please help me resolve error "member names cannot be same as their enclosing type"


    HTML Code:
    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
        /// <summary>
        /// Enter the description of your new custom indicator here
        /// </summary>
        [Description("Enter the description of your new custom indicator here")]
        public class Expiry : Indicator
        {
            #region Variables
            // Wizard generated variables
    		int [] Expiry; 
            // User defined variables (add any user defined variables below)
            #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()
            {
               Expiry = new Int[5];
    			Add(new Plot(Color.FromKnownColor(KnownClor.Orange), PlotStyle.Dot, "Plot0"));
    			CalculateOnBarClose = false;
    			Overlay             = false;
    			PriceTypeSupported  =false;
    			Expiry[0] = 20150326;
    			Expiry[1] = 20150226;
    			Expiry[2] = 20150129;
    			Expiry[3] = 20141225;
    			Expiry[4] = 20141127;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                for( int i=0;i<4;i++)
    			{
    				if(ToDay(Time[0]) == Expiry[i]){Plot0.Set(1); break;}
    			else Plot0.Set(0);
    			}
            }

    #2
    Hello,

    This looks to be caused by a conflict between the class name and one of your variable names.

    public class Expiry : Indicator
    {
    #region Variables
    // Wizard generated variables
    int [] Expiry;

    The Class needs to be unique, this will ultimately be the name of the Indicator, your Variable is the same case and same spelling of Expiry so this would be conflicting.

    Please change either the Name of the indicator by changing the Class name, or change Expiry variable to something not conflicting.

    I look forward to being of further assistance.

    Comment


      #3
      Not able to compile even after name change
      Originally posted by NinjaTrader_Jesse View Post
      Hello,

      This looks to be caused by a conflict between the class name and one of your variable names.

      public class Expiry : Indicator
      {
      #region Variables
      // Wizard generated variables
      int [] Expiry;

      The Class needs to be unique, this will ultimately be the name of the Indicator, your Variable is the same case and same spelling of Expiry so this would be conflicting.

      Please change either the Name of the indicator by changing the Class name, or change Expiry variable to something not conflicting.

      I look forward to being of further assistance.

      Comment


        #4
        Hello,

        I looked over the code and created a new indicator from your partial post,

        It looks like you have a mis spelling as well as an invalid type.

        After you change Expiry to any other name, you will also need to change the line:

        Code:
        Add(new Plot(Color.FromKnownColor([B]KnownClor[/B].Orange), PlotStyle.Dot, "Plot0"));
        This would need to be KnownColor, color is spelled incorrect. This can be changed to simply:

        Code:
        Add(new Plot(Color.Orange, PlotStyle.Dot, "Plot0"));
        Additionally where you are assigning a value to Expiry:

        Code:
            Expiry = new Int[5];
        int should not be capitalized, in the NinjaScript editor you will see the difference for this by color, if the type is correct it will be blue, if it is not correct it would be black and you should also get an error.

        I look forward to being of further assistance.

        Comment


          #5
          Thanks Jesse please check the following errors

          Originally posted by NinjaTrader_Jesse View Post
          Hello,

          I looked over the code and created a new indicator from your partial post,

          It looks like you have a mis spelling as well as an invalid type.

          After you change Expiry to any other name, you will also need to change the line:

          Code:
          Add(new Plot(Color.FromKnownColor([B]KnownClor[/B].Orange), PlotStyle.Dot, "Plot0"));
          This would need to be KnownColor, color is spelled incorrect. This can be changed to simply:

          Code:
          Add(new Plot(Color.Orange, PlotStyle.Dot, "Plot0"));
          Additionally where you are assigning a value to Expiry:

          Code:
              Expiry = new Int[5];
          int should not be capitalized, in the NinjaScript editor you will see the difference for this by color, if the type is correct it will be blue, if it is not correct it would be black and you should also get an error.

          I look forward to being of further assistance.

          Comment


            #6
            Hello,

            Thank you for the image.

            This tells us exactly what is wrong based on the error text.

            The first error listed says the name "expiry" does not exist which is correct, C# is case sensitive, you have created a variable with the name Expiry not expiry, so you would need to correct the case so they all match.

            The next item is the same line, again Int would be invalid as you have Int capitalized. You need to make Int into int with a lowercase I.

            The next errors: Plot0 does not exist, this would be related to the public property.

            If you expand the region "Properties, if you do not have this segment of code, this would be the reason:

            Code:
            [Browsable(false)]
            [XmlIgnore()]
            public DataSeries Plot0
            {
            	get { return Values[0]; }
            }
            This defines the Plot0 you created in Initialize, this will be setting Values index 0 with the value you pass using Plot0.Set();

            The errors displayed will always tell you what is happening in the script, if in doubt you can also double click the error to take the cursor to the location of the general error.

            I look forward to being of further assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            581 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            338 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X