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

Does NT7 works using quick get/set ?

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

    Does NT7 works using quick get/set ?

    Hi. I knew that only NT8 worked with such property declarations:

    Code:
    		[Gui.Design.DisplayName("my param")]
    		public int myPeriod {
    			get; set;
    		}
    However, I've checked and it also seems to work well in NT7 ( I set the default value of 'myPeriod ' in initialize).


    So, was there an update in NT7? or what's difference if using :

    Code:
    		
    		[Gui.Design.DisplayName("my param")]
    		public int myPeriod {
    			get { return xyz; }  set { xyz= value; }
    		}
                    private int xyz = 4;

    #2
    Hello,

    Thank you for the post.

    There was no update in this case, the Auto-Implemented properties were just not used in in any of the samples for NT7. The getter/setter property you have shown is C# specific not related to NinjaTrader.

    You can either use a backing property or not with a public property, that depends on its overall use.

    The most simple and easiest way to use a public property it to use just get;set; or Auto-Implemented form:
    Code:
    public int myPeriod 
    {
    	get; set;
    }
    You can also define a backing field for other use cases:
    Code:
    public int myPeriod 
    {
    	get { return xyz; }  set { if(value > 10) xyz = 10; else xyz= value; }
    }
    private int xyz = 4;
    A backing field allows you to use the method body form of the property which just allows you to do extra logic in the body of the property while getting or setting its value.

    For more information on this and other concepts in C#, I would suggest reviewing the content at MSDN as it is very educational:



    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by TraderBCL, Today, 04:38 AM
    2 responses
    17 views
    0 likes
    Last Post TraderBCL  
    Started by martin70, 03-24-2023, 04:58 AM
    14 responses
    106 views
    0 likes
    Last Post martin70  
    Started by Radano, 06-10-2021, 01:40 AM
    19 responses
    609 views
    0 likes
    Last Post Radano
    by Radano
     
    Started by thanajo, 05-04-2021, 02:11 AM
    4 responses
    471 views
    0 likes
    Last Post tradingnasdaqprueba  
    Started by aa731, Today, 02:54 AM
    0 responses
    5 views
    0 likes
    Last Post aa731
    by aa731
     
    Working...
    X