Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Indicator with ICustomTypeDescriptor in Market Analyzer

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

    Using Indicator with ICustomTypeDescriptor in Market Analyzer

    Hi,

    I have developed an Indicator with dynamic properties, which works fine for Chart. TO handle the Dynamic Properties, I used ICustomTypeDescriptor in class definition:
    Code:
    public class myIndicator : Indicator, ICustomTypeDescriptor
        {
    I am trying to use the same indicator in a column of a Market Analyzer. When I select the Indicator the widget area turn white. If I remove the ICustomTypeDescriptor, it works well, except the properties don't change dynamically (important functionality).

    Any help?

    #2
    Hi Shai Samuel,

    Thanks for your patience while I checked this out.

    In your script, are you setting any of the property descriptors to null in the property descriptor collection?

    From testing, I am finding that null values will cause this behavior.

    Attached is an example script that does not set to null but instead disables properties and this appears to be working ok.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chelsea.

      Yes, my script actually hide the property, "delete" it from the list, by placing null, at its value.

      The script you attached as an example, leave the property in place and make it readonly. My challenge, is with many properties, it makes the interface very busy, and less readable.

      Thanks to your help, I am looking now into a 3rd approach, which basically rebuild the property list, based on the required properties at a given scenario.

      If I may ask for additional help here (very significant for me), what is the way to identify when the Indicator is loaded to a Chart or into a Market Analyzer column?

      Comment


        #4
        My final solution...

        Dear Chelsea,

        After evaluating all, I found a very simple solution how to fix the script that works well with the Chart, to over come the null issue. Basically, I remove the null values, after setting them up, as you can see in the attached example.

        Basically I replaced the code:
        Code:
                public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
                {
                    PropertyDescriptorCollection originalCollection = TypeDescriptor.GetProperties(GetType(), attributes);
                    PropertyDescriptor[]		 updatedProperties  = new PropertyDescriptor[originalCollection.Count];
                    originalCollection.CopyTo(updatedProperties, 0);
        			ModifyProperties(updatedProperties);			
                    return new PropertyDescriptorCollection(updatedProperties);
                }

        With the code:
        Code:
               public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
                {
                    PropertyDescriptorCollection originalCollection = TypeDescriptor.GetProperties(GetType(), attributes);
                    PropertyDescriptor[]		 updatedProperties  = new PropertyDescriptor[originalCollection.Count];
                    originalCollection.CopyTo(updatedProperties, 0);
        			ModifyProperties(updatedProperties);			
        			return RemovePropertyDescriptorCollectionNulls(new PropertyDescriptorCollection(updatedProperties));
        		}
        		// this is the change from pervius version, that fixes the issue with Market Anayzer (not allowing null value)
        		private PropertyDescriptorCollection RemovePropertyDescriptorCollectionNulls(PropertyDescriptorCollection pdc)
        		{
        			int idx=0;
        			while (idx<pdc.Count)
        			{				
        				if (pdc[idx]==null) 	
        					pdc.RemoveAt(idx); 
        				else
        					idx++;
        			}
        			return pdc;
        		}
        So I hope this can help others as well.

        My questions remains the same: what is the way to identify when the Indicator is loaded to a Chart or into a Market Analyzer column?
        Attached Files

        Comment


          #5
          Hi Shai Samuel,

          For now, the only method I am aware of is to check if (ChartControl != null) in OnStartUp(). OnStartUp() is not run until the script is started though.

          If I find any other way I will post to this thread.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Thank you Chelsea, that can work.

            Is there anything like ChartControl for MA?

            I would like to Activate much like Chart, to use some modified properties by the code.

            Comment


              #7
              Hi Shai Samuel,

              There is not a property that exists for the Market Analyzer in NT7. I'm looking into seeing if there is a way to detect the Market Analyzer in NT8.

              For NT7, the best you could check is that ChartControl is null. If it is, you at least know it is not on a chart.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by Shai Samuel View Post
                Thank you Chelsea.

                Yes, my script actually hide the property, "delete" it from the list, by placing null, at its value.

                The script you attached as an example, leave the property in place and make it readonly. My challenge, is with many properties, it makes the interface very busy, and less readable.

                Thanks to your help, I am looking now into a 3rd approach, which basically rebuild the property list, based on the required properties at a given scenario.

                If I may ask for additional help here (very significant for me), what is the way to identify when the Indicator is loaded to a Chart or into a Market Analyzer column?
                Try setting the IsBrowsable property (with or without setting the IsReadOnly property).

                Code:
                            public override bool IsBrowsable
                            {
                                get { return false; }
                            }
                Remember to decorate the indicator properties with the Browsable Attribute.

                ref: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

                Comment


                  #9
                  Thanks koganam, but I found the way to make it work. Please see my post #4. It works like a charm.

                  Comment


                    #10
                    Originally posted by Shai Samuel View Post
                    Thanks koganam, but I found the way to make it work. Please see my post #4. It works like a charm.
                    Oops, did not see that. That will teach me to refresh the windows before I respond.

                    Comment


                      #11
                      Hi Shai Samuel,

                      For NT8 it is possible to detect that the script was added to the MarketAnalyzer.

                      Code:
                      if (Parent is MarketAnalyzerColumnBase)
                      {
                      	Print("Running on a Market Analyzer");
                      }
                      This is not possible with NinjaTrader 7.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Thank you. We will have to wait for just a while longer... NT8 make much more sense...

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by judysamnt7, 03-13-2023, 09:11 AM
                        4 responses
                        59 views
                        0 likes
                        Last Post DynamicTest  
                        Started by ScottWalsh, Today, 06:52 PM
                        4 responses
                        36 views
                        0 likes
                        Last Post ScottWalsh  
                        Started by olisav57, Today, 07:39 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post olisav57  
                        Started by trilliantrader, Today, 03:01 PM
                        2 responses
                        21 views
                        0 likes
                        Last Post helpwanted  
                        Started by cre8able, Today, 07:24 PM
                        0 responses
                        10 views
                        0 likes
                        Last Post cre8able  
                        Working...
                        X