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

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 Steve L, Today, 05:01 PM
            0 responses
            3 views
            0 likes
            Last Post Steve L
            by Steve L
             
            Started by Trader-Joe, Today, 04:06 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_ShawnB  
            Started by vantojo, Today, 04:06 PM
            0 responses
            2 views
            0 likes
            Last Post vantojo
            by vantojo
             
            Started by tonynt, Today, 02:39 PM
            2 responses
            12 views
            0 likes
            Last Post tonynt
            by tonynt
             
            Started by StevenNelson, Today, 12:23 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_PatrickG  
            Working...
            X