Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom Class in properties

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

    Custom Class in properties

    See attached indicator sample

    I have a indicator property, property is my class type (MyStroke)
    indicator can serialize from/to template fine
    but when recompile the indicator and load the chart it fail with error:

    Error on getting/setting property 'MyProp' for NinjaScript 'CustomProp': Object of type 'NinjaTrader.NinjaScript.Indicators.CustomProp+MyS troke' cannot be converted to type 'NinjaTrader.NinjaScript.Indicators.CustomProp+MyS troke'.

    I had it working on NT7 fine, I guess I am missing something to help NT8 serialize the property correctly not not sure what.
    Attached Files

    #2
    Originally posted by Raditz View Post
    See attached indicator sample

    I have a indicator property, property is my class type (MyStroke)
    indicator can serialize from/to template fine
    but when recompile the indicator and load the chart it fail with error:

    Error on getting/setting property 'MyProp' for NinjaScript 'CustomProp': Object of type 'NinjaTrader.NinjaScript.Indicators.CustomProp+MyS troke' cannot be converted to type 'NinjaTrader.NinjaScript.Indicators.CustomProp+MyS troke'.

    I had it working on NT7 fine, I guess I am missing something to help NT8 serialize the property correctly not not sure what.
    You will have to write a custom PropertyDescriptor for your class if you want to expose its instance as public.

    Comment


      #3
      Hello Raditz,

      While koganam is likely correct and the class needs a custom property descriptor added to the indicator property descriptor collection, I am unable to reproduce the error you are receiving using your script.

      I would like to check to see if a change with the latest public Beta version is preventing the error on my end.

      I would like you to uninstall NinjaTrader 8, then rename your NinjaTrader 8 folder in Documents, re-install, add this one script by itself, and then retest.

      If needed, below is a link to the downloads page where you can download the latest public beta.
      http://ninjatrader.com/PlatformDirect

      If you are still able to reproduce, send in an email to platformsupport [at] ninjatrader [dot] com so that we can schedule a call and I can do further testing on your end. In the email, please include a link to this forum thread.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hello Raditz,

        Further follow up with an example of the property discriptor / type converter can be found in one of NinjaTrader_Jesse's posts.

        http://ninjatrader.com/support/forum...838#post447838

        However, I am still unable to reproduce the error with your script and I would like you to test for the behavior with a new NT8 folder.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Tried to add

          [TypeConverter(typeof(ExpandableObjectConverter))]

          See attached

          Also removed and installed new NT8, still happen

          Sent email, also available now

          Comment


            #6
            Hello, after spending the last few days on this, I'm resorting to looking for help. I'm having a similar error as the OP.

            In order to illustrate my goal, I've created a simple example (attached) where I have an Indicator that utilizes a param similar to PriceLevels (used in many of the Fib drawing tools).

            I've duplicated the PriceLevel, Converter, and Container (renaming them all to "my") and extended my Indicator class to the Container.

            I cannot get it to remember any levels I add to it, nor properly set default levels, plus I get the "Error on getting/setting property" error when I rebuild (like the OP).

            Ultimately, I would like to go one step further and extend the Container to another Indicator (such as the ZigZag, for example), but I can't even get this simple situation to work. Maybe I'm making this more complicated than it needs to be?
            Attached Files

            Comment


              #7
              Hello neoikon,

              I am uncertain of what you are trying to accomplish. However, this looks to be far outside of the realm of NinjaTrader Support.

              It looks as if you are trying to extend an indicator which I would not recommend and I do not think will work.

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

              You can also contact one of our professional NinjaScript Consultants who would be eager to create or modify this script at your request or assist you with your script. Please let me know if you would like our business development follow up with you with a list of professional NinjaScript Consultants who would be happy to create this script or any others at your request.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Thank you for the quick reply. Perhaps I wasn't very clear.

                I'm simply wanting to add the PriceLevels variable to an indicator. (the same variable that appears in the fibonacci retracements drawing tool (or similar), except this is an indicator)

                Comment


                  #9
                  Hello neoikon,

                  The PriceLevels object is an object that is constructed in the core for drawing objects when initialized that is not available to indicators.
                  http://ninjatrader.com/support/helpG...ricelevels.htm

                  This is used for the property grid for drawing objects that have multiple levels that can be configured by the user.

                  These price levels do not apply to indicators and would not show in the indicator window property grid.

                  In your indicator you could make some inputs that have different price levels and brushes with a custom class object and achieve the same effect.

                  Attached is an example I've made previously of a custom class object.
                  Attached Files
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Correct, I understand that PriceLevels is a DrawingTools object. I'm talking about doing something similar, but for an Indicator (copy and pasting and renaming objects, as in my attached example from earlier). In the end, what I would build would be nothing like the PriceLevels, but I use it as an example, since it's built-in and documented.

                    I just want to create a param that allows an unlimited list of items (like the PriceLevels object)... but in an Indicator.

                    After working on this further, I believe I have something working (allows me to set some defaults and saves changes to the list). However, I am still getting that "Error on getting/setting property..." error after a rebuild, which I think is a TypeConverter issue. I've used the ExpandableObjectConverter method as well as custom with the same result. I'm not sure how to debug it, unfortunately.

                    Comment


                      #11
                      Hello neoikon,

                      Adding new objects to a property grid on the fly the way price levels are added is far outside of the realm of NinjaScript support.

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

                      NinjaTrader_Jesse has made an example addon that uses a property grid, however, keep in mind this is not supported by NinjaTrader support to do.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks for the reply, but that doesn't seem to apply to what I'm talking about. It's more of a collection or List<> or "NinjaTrader.Gui.Tools.CollectionEditor"... and not a Property Grid.
                        Last edited by neoikon; 08-05-2016, 04:00 PM.

                        Comment


                          #13
                          Hello neoikon,

                          I may not have understood your inquiry correctly.

                          Were we not talking about replicating the price levels property grid that can be accessed from the properties of a fibonacci drawing object?
                          (Click on the value and this opens a new property grid where levels can be added / removed)

                          If not, can you further describe what you are trying to do?
                          Chelsea B.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by futtrader, 04-21-2024, 01:50 AM
                          4 responses
                          41 views
                          0 likes
                          Last Post futtrader  
                          Started by Option Whisperer, Today, 09:55 AM
                          1 response
                          11 views
                          0 likes
                          Last Post bltdavid  
                          Started by port119, Today, 02:43 PM
                          0 responses
                          2 views
                          0 likes
                          Last Post port119
                          by port119
                           
                          Started by Philippe56140, Today, 02:35 PM
                          0 responses
                          3 views
                          0 likes
                          Last Post Philippe56140  
                          Started by 00nevest, Today, 02:27 PM
                          0 responses
                          2 views
                          0 likes
                          Last Post 00nevest  
                          Working...
                          X