Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get a ModifyProperties() call

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

    How to get a ModifyProperties() call

    I know an indicator can implement ICustomTypeDescriptor and that gives it a hook to modify properties.

    I have some expandable objects, intended to be used as expandable properties by my indicators. Since they are not themselves indicators I have put the code in the AddOns folder, which is what I believe is advised.

    If they also implement ICustomTypeDescriptor can I arrange that they will get called? I know that I could call them from the indicator (but would that do any good?), but I am hoping they can be more independent than that. Perhaps if they subclass something in particular?

    For now I'm going to just call them from the indicator, but I would welcome a suggestion to eliminate that coupling.

    --EV
    Last edited by ETFVoyageur; 08-14-2016, 12:27 AM.

    #2
    Hello EV,

    Currently, custom type descriptors / type converters are not supported by NinjaTrader Support.

    Our development is currently discussing putting together 3rd party developer customizations of this nature, but at this time our support would not be able to assist with this.

    This thread will remain open for any community members that would like to assist.


    That said, if you are able to get ICustomTypeDescriptor working to modify properties, you should be able to add this to an addon in the indicator namespace or in its own custom namespace.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    }

    Below is a link to an example of adding items to an addon file.



    Also, you could instead of using a custom type descriptor and converter, inherit from the Gui.DrawingTools.DrawingToolPropertiesConverter. The regression channel drawing tool does this so that when the Mode is set to Segment the standard deviation distances are disabled dynamically. This may be possible to use in an indicator and could be used to modify how properties appear in the grid (if this is your goal).


    Custom expandable properties can be achieved without creating a custom type descriptor class.
    Last edited by NinjaTrader_ChelseaB; 08-15-2016, 09:50 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Chelsea,

      Thanks for all of your suggestions

      ICustomTypeDescriptor worked for indicators in V7 -- I keyed off that to dynamically hide properties in the Indicators dialog.

      I am just getting started on the equivalent code for V8. I very much hope I shall be able to accomplish the equivalent of what I could do in V7.

      --EV

      Comment


        #4
        Chelsea,

        FWIW: in V8, the critical ICustomTypeDescriptor function PropertyDescriptorCollection GetProperties(Attribute[] attributes)() does get called. That's good, because that is the hook for modifying properties dynamically, as I did in V7

        --EV

        Comment


          #5
          Hello EV,

          Are you certain you are trying to modify the ICustomTypeDescriptor class?

          It sounds more like you are trying to modify the properties themselves in a TypeConverter. (The ICustomTypeDescriptor would be the descriptor of the property but this class does not provide the GetProperties or GetPropertiesSupported methods which are part of the TypeConverter class)
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            The function is part of the interface. It returns a collection of properties. The function can omit properties in the collection it returns. It could omit some in the morning, and different ones in the afternoon if that's what it felt like doing.

            If there is a simpler way to dynamically omit/include properties from the Indicators dialog, I am not aware and would welcome being told how to do so.

            --EV

            Comment


              #7
              Hello EV,

              I'm not sure that I can further comment on this, as my understanding is this would be part of the TypeConverter class.

              However, this thread will remain open for any community members that would like to assist.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_ChelseaB View Post
                Hello EV,

                Are you certain you are trying to modify the ICustomTypeDescriptor class?

                It sounds more like you are trying to modify the properties themselves in a TypeConverter. (The ICustomTypeDescriptor would be the descriptor of the property but this class does not provide the GetProperties or GetPropertiesSupported methods which are part of the TypeConverter class)
                I am not trying to modify anything; I am trying to provide that interface. My implementation largely depends on the non-custom TypeDescriptor. Here is the implementation. ModifyProperties() is my own function where I modify the collection as desired before it is returned. Works fine in V7, and I expect it will work fine in V8 since the needed function is getting called.

                --EV

                Code:
                        #region ICustomTypeDescriptor Members
                        public AttributeCollection GetAttributes()                            { return TypeDescriptor.GetAttributes(GetType()); }
                        public string GetClassName()                                        { return TypeDescriptor.GetClassName(GetType()); }
                        public string GetComponentName()                                    { return TypeDescriptor.GetComponentName(GetType()); }
                        public TypeConverter GetConverter()                                    { return TypeDescriptor.GetConverter(GetType()); }
                        public EventDescriptor GetDefaultEvent()                            { return TypeDescriptor.GetDefaultEvent(GetType()); }
                        public PropertyDescriptor GetDefaultProperty()                        { return TypeDescriptor.GetDefaultProperty(GetType()); }
                        public object GetEditor(Type editorBaseType)                        { return TypeDescriptor.GetEditor(GetType(), editorBaseType); }
                        public EventDescriptorCollection GetEvents()                        { return TypeDescriptor.GetEvents(GetType()); }
                        public EventDescriptorCollection GetEvents(Attribute[] attributes)    { return TypeDescriptor.GetEvents(GetType(), attributes); }
                        public PropertyDescriptorCollection GetProperties()                    { return TypeDescriptor.GetProperties(GetType()); }
                        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
                        {
                            PropertyDescriptorCollection orig = TypeDescriptor.GetProperties(GetType(), attributes);
                            PropertyDescriptor[] arr = new PropertyDescriptor[orig.Count];
                            orig.CopyTo(arr, 0);
                            PropertyDescriptorCollection col = new PropertyDescriptorCollection(arr);
                            ModifyProperties(col);  // This is the hook for us to eliminate any we wish to
                            return col;
                        }
                        public object GetPropertyOwner(PropertyDescriptor pd) { return this; }
                        #endregion

                Comment


                  #9
                  I am happy to report that my investigation shows the interface is honored for expandable objects as well as for indicators. I have not checked any further, since that is all I need, so I do not know which objects in general get called.

                  --EV

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by r68cervera, Today, 05:29 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post r68cervera  
                  Started by geddyisodin, Today, 05:20 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post geddyisodin  
                  Started by JonesJoker, 04-22-2024, 12:23 PM
                  6 responses
                  33 views
                  0 likes
                  Last Post JonesJoker  
                  Started by GussJ, 03-04-2020, 03:11 PM
                  12 responses
                  3,239 views
                  0 likes
                  Last Post Leafcutter  
                  Started by AveryFlynn, Today, 04:57 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post AveryFlynn  
                  Working...
                  X