Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Now with .net 8.0 are we allowed to use autoproperties for setting default values?

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

    Now with .net 8.0 are we allowed to use autoproperties for setting default values?

    Hello,

    I've always disliked how properties are set up in NT8, the properties are set right at the bottom of the file, and the defaults are set inside State == State.SetDefaults at the top of the file, so much scrolling or navigation if a program gets too big, even worse I see it's common for some to use the property with a backing field, that's like 10 - 14 lines for a single property as I've seen in some cases.

    Now with .NET 8 we can do the following, but I'm not sure if this can bring some unintended consequences with the UI or the bots/indicators, so far, I haven't seen a problem, would like to get some feedback if this is allowed now:

    Code:
    [NinjaScriptProperty, Display(Name = "Set Profit Target", Order = 14, GroupName = "Target")]
    public bool PropProfitTarget { get; set; } = true;
    Thanks!​

    #2
    Hello Waxavi,

    This is C#.. you can declare variables at the top of the class if you want to. And you can assign CategoryOrder to be at the top as well.
    https://ninjatrader.com/support/help...rattribute.htm

    The Order of the Display attribute can be specified as well within a Category.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      My bad, C# 8 not .NET 8, and thanks for your response.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      563 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      329 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      547 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      548 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X