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

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.
    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        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.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by andrewtrades, Today, 04:57 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by chbruno, Today, 04:10 PM
            0 responses
            6 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Started by josh18955, 03-25-2023, 11:16 AM
            6 responses
            436 views
            0 likes
            Last Post Delerium  
            Started by FAQtrader, Today, 03:35 PM
            0 responses
            7 views
            0 likes
            Last Post FAQtrader  
            Started by rocketman7, Today, 09:41 AM
            5 responses
            19 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X