Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Removing Properties from Indicator causes compile error

Collapse
X
 
  • 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.

    #2
    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".

    Comment


      #3
      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

      Comment


        #4
        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


        #Variables
        private int myVariable =0;
        private int myVariable2 =0;


        and in the properties section like this

        #Properties
        [Description("Integer Line Width")]
        [Category("Parameter")]

        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 && .....
        ......
        ......
        cache__INDI_NAME[idx].EqualsInput(input))
        return cache__INDI_NAME[idx];


        Thanks again for your help, best regard.

        Comment


          #5
          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

          Comment


            #6
            Hi Chris,

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

            Thanks again.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by adeelshahzad, Today, 03:54 AM
            4 responses
            25 views
            0 likes
            Last Post adeelshahzad  
            Started by merzo, 06-25-2023, 02:19 AM
            10 responses
            823 views
            1 like
            Last Post NinjaTrader_ChristopherJ  
            Started by frankthearm, Today, 09:08 AM
            5 responses
            17 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            43 views
            0 likes
            Last Post jeronymite  
            Started by yertle, Today, 08:38 AM
            5 responses
            16 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X