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

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.
          JimNinjaTrader 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
          4 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