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

NT Incorrectly Parsing Recursive Properties

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

    NT Incorrectly Parsing Recursive Properties

    A bug: NT is parsing recursive properties using an algorithm that is not truly type-checking ... and anyway, will incorrectly warn about recursive properties.

    To reproduce: create the following indicator:

    Code:
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    
    namespace NinjaTrader.Indicator
    {
        public class TestIndicator : Indicator
        {
            public class Foo
    		{
    			private bool bar = false;
    			
    			public bool Bar {
    				get { return bar; }
    				set { bar = value; }
    			}
    		}
    		
    		private Foo foo = new Foo();
    
            protected override void Initialize()
            {
            }
    
            protected override void OnBarUpdate()
            {
            }
    
            [Description("")]
            [GridCategory("Parameters")]
            public bool Bar
            {
                get { return foo.Bar; }
                set { foo.Bar = value; }
            }
        }
    }
    NT will warn that the Bar property is recursive. Further, when issuing the warning, NT will highlight the Bar property on foo.Bar -- not in the same namespace.

    MORE: if you actually COMMENT OUT the property, as below:

    Code:
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    
    namespace NinjaTrader.Indicator
    {
        public class TestIndicator : Indicator
        {
            public class Foo
    		{
    			private bool bar = false;
    			
    			public bool Bar {
    				get { return bar; }
    				set { bar = value; }
    			}
    		}
    		
    		private Foo foo = new Foo();
    
            protected override void Initialize()
            {
            }
    
            protected override void OnBarUpdate()
            {
            }
    
    //        [Description("")]
    //        [GridCategory("Parameters")]
    //        public bool Bar
    //        {
    //            get { return foo.Bar; }
    //            set { foo.Bar = value; }
    //        }
        }
    }
    NT will STILL WARN about a recursive property; even though here there is no such property.
    Attached Files

    #2
    steevcoco,

    This is because the get and set value is using the same public name for the user defined input.

    Try renaming the user defined input to Bar1 or something else
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      I see. It still seems odd to me since they are not in the same namespace (there is no conflict on compilation). I did do as you suggested.

      Can you explain why NT still warns when the property is commented out?

      ... Thanks in any case!

      Comment


        #4
        Originally posted by steevcoco View Post
        I see. It still seems odd to me since they are not in the same namespace (there is no conflict on compilation). I did do as you suggested.

        Can you explain why NT still warns when the property is commented out?

        ... Thanks in any case!
        You are trying to use an internal NT event handler as a variable. That is why you are seeing strangeness. Bar is the BarUpdateEventHandler Bars.Bar.

        Comment


          #5
          Hello steevcoco,

          Koganam's observation would be correct, as Bar would already exist in NinjaScript. Why it is still warning after being commented out would lead me to believe it is still referenced int eh code somewhere or you have not compiled since commenting out the lines.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by tkaboris, Today, 05:13 PM
          0 responses
          2 views
          0 likes
          Last Post tkaboris  
          Started by GussJ, 03-04-2020, 03:11 PM
          16 responses
          3,281 views
          0 likes
          Last Post Leafcutter  
          Started by WHICKED, Today, 12:45 PM
          2 responses
          19 views
          0 likes
          Last Post WHICKED
          by WHICKED
           
          Started by Tim-c, Today, 02:10 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by Taddypole, Today, 02:47 PM
          0 responses
          5 views
          0 likes
          Last Post Taddypole  
          Working...
          X