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

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 StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,964 views
      3 likes
      Last Post jhudas88  
      Started by rbeckmann05, Today, 06:48 PM
      0 responses
      4 views
      0 likes
      Last Post rbeckmann05  
      Started by rhyminkevin, Today, 04:58 PM
      4 responses
      52 views
      0 likes
      Last Post dp8282
      by dp8282
       
      Started by iceman2018, Today, 05:07 PM
      0 responses
      5 views
      0 likes
      Last Post iceman2018  
      Started by lightsun47, Today, 03:51 PM
      0 responses
      8 views
      0 likes
      Last Post lightsun47  
      Working...
      X