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

Is there a way to force a refresh of the data series from a BarsTypes?

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

    Is there a way to force a refresh of the data series from a BarsTypes?

    Long story short: we are successfully loading in some custom values in our BarsType using a custom PropertyDescriptor, using code that looks something like this:

    Code:
    public class CustomValueDescriptor : PropertyDescriptor
    {
    
    public override object GetValue(object component)
    {
    ............
    }
    
    public override void SetValue(object component, object value)
    {
    .............
    }
    
    }
    (plus a bunch of extra stuff)


    However, when we update our settings, we are only able to get the new settings to alter the BarsType rendering if we also update one of the internal Ninjatrader Values as a second step. Ie (Value, Value2, or BaseBarsPeriodValue). This is annoying and/or confusing since you end up needing 3 steps to make a change:

    1 - change custom value
    2 - change an internal value to something else
    3 - change internal value back to what it was

    And only then we can see the result of our changed custom value.

    I realize this is a hack, and not a supported method.... But, is there a way for me to force a Data refresh? Force a call of OnDataPoint, perhaps?

    #2
    Hello torch2k,

    I am not aware of any way to refresh the data as you mentioned. If you are adding custom properties to a BarsType that would be outside of what is supported and may not work. The BarsTypes utilize the existing internal properties and property renaming for creating custom properties.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello torch2k,

      I am trying to add a new property to a new CustomBarsType so it will be shown in the data series grid. Since you wrote that you got it to work. maybe you could help me out.

      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 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));
      }
      }
      }
      }

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by SantoshXX, Today, 03:09 AM
      0 responses
      11 views
      0 likes
      Last Post SantoshXX  
      Started by DanielTynera, Today, 01:14 AM
      0 responses
      2 views
      0 likes
      Last Post DanielTynera  
      Started by yertle, 04-18-2024, 08:38 AM
      9 responses
      41 views
      0 likes
      Last Post yertle
      by yertle
       
      Started by techgetgame, Yesterday, 11:42 PM
      0 responses
      12 views
      0 likes
      Last Post techgetgame  
      Started by sephichapdson, Yesterday, 11:36 PM
      0 responses
      2 views
      0 likes
      Last Post sephichapdson  
      Working...
      X