Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Hide/Show UserDefinedValues properties in MarketAnalyzerColumns

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

    Hide/Show UserDefinedValues properties in MarketAnalyzerColumns

    I tried hide some row in properties in my Market Analyzer Columns. I used converter from official pivots indicator, but this code expands all options in my properties... Where is mistake please?


    [TypeConverter("NinjaTrader.Custom.ResourceEnumConv erter")]
    public enum Delta

    {
    actual_bar,
    first_bar_back,
    second_bar_back,
    third_bar_back,
    average
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns.Moje
    {
    [TypeConverter("NinjaTrader.NinjaScript.Indicators. DeltaMMTypeConverter")]
    public class DeltaMM: MarketAnalyzerColumn

    .
    .
    .
    .
    .

    #region Properties

    [NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Delta", Description = "", GroupName = "Parameters", Order = 0)]
    [RefreshProperties(RefreshProperties.All)]
    public Delta Delta
    {
    get { return choose; }
    set { choose = value; }
    }

    [NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "UserDefinedClose", GroupName = "Parameters", Order = 1)]
    public double UserDefinedClose
    {
    get { return userDefinedClose; }
    set { userDefinedClose = value; }
    }

    #endregion
    }

    public class DeltaMMTypeConverter : NinjaTrader.NinjaScript.IndicatorBaseConverter
    {
    public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; }

    public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
    {
    PropertyDescriptorCollection propertyDescriptorCollection = base.GetPropertiesSupported(context) ? base.GetProperties(context, value, attributes) :
    TypeDescriptor.GetProperties(value, attributes);

    Delta Delta = (Delta) value;
    Delta selectedDelta = Delta.actual_bar;

    if (selectedDelta == Delta.first_bar_back)
    return propertyDescriptorCollection;

    PropertyDescriptorCollection adjusted = new PropertyDescriptorCollection(null);
    foreach (PropertyDescriptor thisDescriptor in propertyDescriptorCollection)
    {
    if (thisDescriptor.Name == "UserDefinedClose")
    adjusted.Add(new PropertyDescriptorExtended(thisDescriptor, o => value, null, new Attribute[] {new BrowsableAttribute(false), }));
    else
    adjusted.Add(thisDescriptor);
    }
    return adjusted;
    }
    }
    }


    I would like show row "UserDefinedClose" when enum Delta = first_bar_back...

    #2
    Hello, I edited my script code... now row "UserDefinedClose" show me when enum Delta is first_bar_back... (image 1 and 2). But this code showes me some new properties too (red frames), whiches i dont have in my code... Does anyone know where the error is please? It should only show the properties from image 3 correctly.


    [TypeConverter("NinjaTrader.Custom.ResourceEnumConv erter")]
    public enum Delta

    {
    actual_bar,
    first_bar_back,
    second_bar_back,
    third_bar_back,
    average
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    [TypeConverter("NinjaTrader.NinjaScript.MarketAnaly zerColumns.DeltaMMTypeConverter")]
    public class DeltaMM : MarketAnalyzerColumn
    {
    private Delta choose;
    private double userDefinedClose;

    protected override void OnStateChange()
    {
    .
    .
    .
    .
    .

    }

    #region Properties
    [NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Delta", Description = "", GroupName = "Parameters", Order = 0)]
    [RefreshProperties(RefreshProperties.All)]
    public Delta Choose
    { get { return choose; } set { choose = value; } }

    [NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "UserDefinedClose", GroupName = "Parameters", Order = 1)]
    public double UserDefinedClose
    {
    get { return userDefinedClose; }
    set { userDefinedClose = value; }
    }
    #endregion
    }

    public class DeltaMMTypeConverter : NinjaTrader.NinjaScript.IndicatorBaseConverter
    {
    public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; }

    public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
    {
    PropertyDescriptorCollection propertyDescriptorCollection = base.GetPropertiesSupported(context) ? base.GetProperties(context, value, attributes) : TypeDescriptor.GetProperties(value, attributes);

    DeltaMM Deltas = (DeltaMM) value;
    Delta sDelta = Deltas.Choose;
    if (sDelta == Delta.first_bar_back)
    return propertyDescriptorCollection;

    PropertyDescriptorCollection adjusted = new PropertyDescriptorCollection(null);
    foreach (PropertyDescriptor thisDescriptor in propertyDescriptorCollection)
    {
    if (thisDescriptor.Name == "UserDefinedClose")
    adjusted.Add(new PropertyDescriptorExtended(thisDescriptor, o => value, null, new Attribute[] {new BrowsableAttribute(false), }));
    else
    adjusted.Add(thisDescriptor);
    }
    return adjusted;
    }
    }

    }
    Last edited by phesi; 08-04-2019, 01:29 AM.

    Comment


      #3
      Hello phesi,

      The reference sample in the help guide has a working demonstration of this in Use Case #1.


      The way the properties are being added and removed is different than the logic you have here.

      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Thanks, yes i used it for my indicators, it working correctly, but for indicators or strategy only... i cant not convert it to market analyzer columns... writed me: Unhandled exception: speciefied method is not suported...

        Comment


          #5
          Hello phesi,

          This is Jim, responding on behalf of Chelsea who is out of the office at this time. Thank you for clarifying that you are using this specifically for Market Analyzer Columns,

          Custom TypeConverters are only supported with indicators and strategies at this time. We are tracking interest to expand TypeConverter support by providing a base converter for other NinjaScript types. The ticket ID is SFT-1870 and I have added a vote on your behalf.

          We collect interest in feature requests before determining if the feature should be implemented. For that reason we cannot offer an ETA or promise of fulfillment. Upon implementation, the number for the ticket ID can be publicly found in the Release Notes page of the help guide. I will provide a link below.

          Release Notes - https://ninjatrader.com/support/help...ease_notes.htm

          Let us know if there is anything else we can do to assist.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          602 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          347 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          559 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          559 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X