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

StrategyBaseConverter (Show / hide) properties in analysis

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

    StrategyBaseConverter (Show / hide) properties in analysis

    Hi.
    You can show and hide properties using the converter.

    This also works quite well.

    But when I'm in the optimazer, does that no longer work? Or did I do something wrong then?

    #2
    Hello 1001111,

    That would be expected, the optimizer has its own set of properties which allow the control of ranges. Inside the analyzer strategy based visual changes to the property grid would not be reflected.
    JesseNinjaTrader Customer Service

    Comment


      #3
      HTML Code:
      public class DemoStrategyConverter : StrategyBaseConverter
      {
      
      public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object component, Attribute[] attrs)
      {
      DemoStrategy strategy = component as DemoStrategy;
      
      PropertyDescriptorCollection propertyDescriptorCollection = base.GetPropertiesSupported(context)
      ? base.GetProperties(context, component, attrs)
      : TypeDescriptor.GetProperties(component, attrs);
      if (null == strategy || null == propertyDescriptorCollection)
      {
      return propertyDescriptorCollection;
      }
      
      #region Use Case Show/hide properties based on secondary input
      // These two values are will be shown/hidden (toggled) based on "ShowHideToggle" bool value
      PropertyDescriptor IntOrderStart = propertyDescriptorCollection["IntOrderStart"];
      
      // This removes the following properties from the grid to start off with
      propertyDescriptorCollection.Remove(IntOrderStart) ;
      
      // Now that We've removed the default property descriptors, we can decide if they need to be re-added
      // If "ShowHideToggle" is set to true, re-add these values to the property collection
      if (strategy.IsTradingTime)
      {
      propertyDescriptorCollection.Add(IntOrderStart);
      }
      
      // otherwise, nothing else to do since they were already removed
      #endregion
      
      return propertyDescriptorCollection;
      }
      
      public override bool GetPropertiesSupported(ITypeDescriptorContext context)
      { return true; }
      }

      This allows you to show and hide a property in a strategy.

      But then you can no longer use it in the optimizer because the property is no longer visible.

      How to make the property visible and selectable in the optimizer?

      Comment


        #4
        Hello 1001111,

        As mentioned that won't work in the analyzer and that is expected. You can see that code working when using the control center or a chart. The analyzer rebuilds the properties so that you can optimize them, visual customizations don't work there. If you are having problems because the type converter is working incorrectly in the analyzer it would be suggested to disable that part of the type converter or to not use it while you use the analyzer.
        JesseNinjaTrader Customer Service

        Comment


          #5
          OK thank you.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Graci117, Today, 09:02 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by ETFVoyageur, Today, 07:55 PM
          0 responses
          7 views
          0 likes
          Last Post ETFVoyageur  
          Started by janio973, Today, 07:24 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by aligator, 01-06-2022, 12:14 PM
          4 responses
          248 views
          0 likes
          Last Post john_44573  
          Started by reynoldsn, Today, 05:56 PM
          0 responses
          15 views
          0 likes
          Last Post reynoldsn  
          Working...
          X