Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom properties for Bar Types

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

    Custom properties for Bar Types

    How can we add custom properties to bar types just like we do for indicators & strategies?
    Something like this compiles, but the custom property won't show up in the data series when I select the bar type

    Code:
      public class MyCustomBarType: BarsType
        {
    .....
            [Display( Name = "X offset", GroupName = "01. Colors", Order = 1)]
            public int XOffset { get; set; }
    ...
        }
    EB Worx
    NinjaTrader Ecosystem Vendor - EB Worx

    #2
    Hello EB Worx,

    Thank you for your post.

    When it comes to user inputs for a BarsType script, they don't work the same way as in indicators and strategies. You could use the available default properties, such as Value or Value2, and rename the properties as demonstrated on the SetPropertyName() page here:


    Please let us know if we may be of further assistance.

    Comment


      #3
      Yes i know about these, but is there a way to add any extra custom properties?
      EB Worx
      NinjaTrader Ecosystem Vendor - EB Worx

      Comment


        #4
        Hello EB Worx,

        Thank you for your reply.

        No, there is not a way to add any extra custom properties. BarsType scripts do not work in the same way as Indicators and Strategies when it comes to properties, so you are limited to the properties listed on the SetPropertyName() page linked in my previous post.

        Please feel free to reach out with any additional questions or concerns.

        Comment


          #5
          Hello,
          At this time, in the BarsType.Barsperiod there are only three numerical properties: BaseBarsPeriodValue, Value and Value2.
          It would be possible, in the next release, add more properties to Barsperiod, for example: Value3, Value4, Value5, ...
          It would also be very useful to have a String custom property.
          Thanks​

          Comment


            #6
            Hello,

            with the next code I have been able to add custom properties to the BarsType and show them in the WPFPropertyGrid. But the input field always remains blank and does not save the data introduced. It seems as if the Getvalue and Setvalue methods did not work. Please, could anyone give me any clue why this code is wrong? Any help would be greatly appreciated.

            Click image for larger version

Name:	Captura de pantalla 2024-06-04 234434.jpg
Views:	169
Size:	129.4 KB
ID:	1306125

            Code:
            public class Zb8Debug : BarsType
            {
                // ------------------------------------
                // Step 01 - Declare my custom property
                // ------------------------------------
                [NinjaScriptProperty]
                [Display(Name = "My Property", GroupName = "Data Series", Order = 0)]
                [Range(1, int.MaxValue)]
                public int MyProp{ get; set; }
            
            
                protected override void OnStateChange()
                {
                    if (State == State.SetDefaults)
                    {
                        MyProp = 25;
            
                        Description = @"Enter the description for your new custom Bars type here.";
                        Name = "Zb8Debug";
                        BarsPeriod = new BarsPeriod { BarsPeriodType = (BarsPeriodType)07000001, Value = 1 };
                        DaysToLoad = 3;
                        IsIntraday = true;
                        IsTimeBased = false;
                        BuiltFrom = BarsPeriodType.Tick;
                    }
                    else if (State == State.Configure)
                    {
                        // ----------------------------------------------------------
                        // Step 02 - Add the property to PropertyDescriptorCollection
                        // ----------------------------------------------------------
                        PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this);
                        if (properties != null)
                        {
                            PropertyDescriptor pd1 = properties.Find("MyProp", true);
                            if (pd1 != null)
                                Properties.Add(pd1);
                        }
                    }
                }
            }
            ​
            Last edited by cls71; 06-04-2024, 03:48 PM.

            Comment


              #7
              Hello cls71,

              Adding properties like this to a BarsType script is not supported.

              This thread will remain open for any community members that would like to provide advice for this unsupported approach.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              562 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              325 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
              547 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X