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

Add new properties to the data series grid

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

    Add new properties to the data series grid

    Hello,

    I am trying to add a new property to a new CustomBarsType so it will be shown in the data series grid.

    I implemented a basic CustomPropertyDescriptor and I am trying to add a new property in State.Configure but it is not displayed in the data series grid.

    I will need to add more properties in the future (int, double, bool) so I will not be able to reuse the existing ones.

    I am not sure what I am missing.

    Thank you all in advance.

    Code:
    public class CustomPropertyDescriptor : PropertyDescriptor
    {
    public int CustomParam { get; set; }
    
    public CustomPropertyDescriptor(int value) : base("CustomParam", null) { CustomParam = value; }
    
    public override AttributeCollection Attributes { get { return new AttributeCollection(null); } }
    
    public override bool CanResetValue(object component) { return true; }
    
    public override Type ComponentType { get { return CustomParam.GetType(); } }
    
    public override string DisplayName { get { return "Custom Param"; } }
    
    public override string Description { get { return "Custom Description"; } }
    
    public override object GetValue(object component) { return CustomParam; }
    
    public override bool IsReadOnly { get { return true; } }
    
    public override string Name { get { return "CustomParam"; } }
    
    public override Type PropertyType { get { return CustomParam.GetType(); } }
    
    public override void ResetValue(object component) { }
    
    public override bool ShouldSerializeValue(object component) { return true; }
    
    public override void SetValue(object component, object value) { CustomParam = (int)value; }
    }
    
    public class CustomBarsType : MinuteBarsType
    {
    protected override void OnStateChange()
    {
    base.OnStateChange();
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Bars type here.";
    Name = "CustomBarsType";
    BarsPeriod = new BarsPeriod { BarsPeriodType = (BarsPeriodType)15, Value = 1 };
    BuiltFrom = BarsPeriodType.Minute;
    DaysToLoad = 5;
    IsIntraday = true;
    }
    else if (State == State.Configure)
    {
    if (Properties != null)
    {
    if (Properties.Find("CustomParam", true) == null)
    Properties.Add(new CustomPropertyDescriptor(123));
    }
    }
    }
    }

    #2
    Hello Devside_Victor,

    Thank you for the post.

    Currently it is not supported to add totally new code based properties to a bars type, you can instead use the existing Value and Value2 properties and rename them. This is how the internal types all work by renaming the exiting base properties.

    Please let me know if I may be of additional assistance.

    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Rapine Heihei, 04-23-2024, 07:51 PM
    2 responses
    30 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    943 views
    0 likes
    Last Post spwizard  
    Started by Max238, Today, 01:28 AM
    0 responses
    9 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by rocketman7, Today, 01:00 AM
    0 responses
    7 views
    0 likes
    Last Post rocketman7  
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    28 views
    0 likes
    Last Post wzgy0920  
    Working...
    X