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 pechtri, 06-22-2023, 02:31 AM
    9 responses
    122 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by frankthearm, 04-18-2024, 09:08 AM
    16 responses
    66 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by habeebft, Today, 01:18 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by benmarkal, Today, 12:52 PM
    2 responses
    17 views
    0 likes
    Last Post benmarkal  
    Started by f.saeidi, Today, 01:38 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X