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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      49 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      38 views
      0 likes
      Last Post CarlTrading  
      Working...
      X