• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


Removing Properties from Indicator causes compile error

  • Filter
  • Time
  • Show
Clear All
new posts

    Removing Properties from Indicator causes compile error

    I came across an issue compiling my indicators when removing existing Properties by commenting them out. I no longer want to provide an option for users to change the indicator configuration, but when I comment out the entire section of the properties except data series type properties I get errors like this below.

    'NinjaTrader.Indicator._INDI_NAME' does not contain a definition for 'MyVariable' and no extension method.

    It's generated from this section of the code Ninjatrader generates.
    if (cache_INDI_NAME != null)
    for (int idx = 0; idx < cache_INDI_NAMELength; idx++)
    if (cache_INDI_NAME[idx].MyVariable

    Any help appreciated, thank you in advance.

    Welcome to the forums!

    Is "MyVariable" actually one of the properties you commented out?

    Just so you know ...
    The case of variable names is extremely important -- "myVariable" is not the same as "MyVariable".


      Hello testnet, thanks for your post, and welcome to the NinjaTrader forums.

      If the commented property is being used somewhere in the code be sure to remove it. You can delete the entire "#region NinjaScript generated code" section then re-compile and new code will be generated, does this fix the issue?

      I look forward to hearing from you.

      Chris L.NinjaTrader Customer Service


        Thank you btdavid, and Chris,

        I have been using the lower case version of my variables in all of my code, I have just verified that.

        I am not sure if that is the proper way to access the properties, but it had been working for me. Just for clarification when I have a variable declared as the example below

        private int myVariable =0;
        private int myVariable2 =0;

        and in the properties section like this

        [Description("Integer Line Width")]

        public int MyVariable
        get { return myVariable; }
        set { myVariable = value; }

        Now that my testing phase is done, I don't want user to modify parameters, so I simply want comment out the properties, and leave the variable declarations intact.

        I found some of my indicators where I could comment out 5-10 variable without any issues, and there are others simply won't compile.
        The error is generated when the Ninjatrader cache is compared with my current code base from what I see, but I don't know where this cache can be cleared. And it does look like the compiler is looking for the Upper case property declarations.

        if (cache__INDI_NAME != null)
        for (int idx = 0; idx < cache__INDI_NAME.Length; idx++)
        if (cache__INDI_NAME[idx].MyVariable == myVariable && cache__INDI_NAME[idx].MyVariable2 == myVariable2 && .....
        return cache__INDI_NAME[idx];

        Thanks again for your help, best regard.


          Hello testnet, thanks for your reply.

          There is a known issue in NT7 with using block comments when commenting out public properties (multi line comments: /**/) Please remove that commenting and use the auto line commenter, it is the second icon to the right at the top menu of the NinjaScript editor.

          Kind regards.

          Chris L.NinjaTrader Customer Service


            Hi Chris,

            Thank you for that tip, the one by one commenter option worked perfect.

            Thanks again.


            Latest Posts


            Topics Statistics Last Post
            Started by frankduc, Today, 08:12 AM
            0 responses
            1 view
            Last Post frankduc  
            Started by jertrade, Today, 08:10 AM
            1 response
            Last Post jertrade  
            Started by iq200, Today, 08:05 AM
            0 responses
            1 view
            Last Post iq200
            by iq200
            Started by frantic, Today, 06:37 AM
            1 response
            Last Post NinjaTrader_PatrickG  
            Started by bouncetherubble, Yesterday, 06:56 PM
            1 response
            Last Post NinjaTrader_ChristopherS