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

Custom object type property for indicator - errors with "Clone()"

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

    Custom object type property for indicator - errors with "Clone()"

    Hello,
    I have a following issue with property which is of my custom type (some class with its own properties - I have its custom converter created, it could be serialized into workspace file like a charm).
    When I have used this property in indicator, I'm not able to preserve this indicator for example when data provider is connected. Indicator goes away with an error this property couldn't be loaded and/or implementation has changed. Which is a bull****, of course.
    I found somewhere in here, the indicator's "Clone()" implementation is one big mess where a new instance is created using parameterless contructor and after then all available properties are just copied. Which is something really, really bad.
    However, I think this causes my issue and I don't know how to handle this correctly.

    I have tried also to override a Clone() method to handle this property correctly but I wasn't succesful. Maybe because of the fact, I use in my indicator some (not public) calculation engine class which takes the indicator itself in its constructor parameter. This means, this object can't be created during indicator cloning process as its property is unavailable and it doesn't use parameterless contructor as it has none.

    Could you please help me how can I solve this issue?

    #2
    Hello ku8az,

    Thank you for your post.

    I would need to understand the full case before I could point you in the right direction here.

    Can you provide the full error message from your indicator when you connect to your provider?

    How are you serializing the property? Can you provide an example of the property as well as the custom converter used?

    I look forward to your response.

    Comment


      #3
      Hi Patrick,
      I'd put a message and code samples here after I'll get to my computer. But I think it was something like:

      2017-04-20 15:10:45:048 ERROR: Error on getting/setting property 'SessionSettings' for NinjaScript 'MyIndicator': Exception has been thrown by the target of an invocation.
      2017-04-20 15:10:45:051 ERROR: Unable to create instance of NinjaScript 'MyIndicator'. Most likely either the implementation no longer exists, there is no default constructor defined, the default constructor does not work correctly, or the 'OnStateChange' implementation for State=SetDefaults is flawed: System.InvalidOperationException: 'DrawHorizontalGridLines' cannot be set from this state. Please see the Help Guide article on 'DrawHorizontalGridLines' for more information. at NinjaTrader.NinjaScript.IndicatorBase.set_DrawHori zontalGridLines(Boolean value) at NinjaTrader.NinjaScript.IndicatorBase.CopyTo(Ninja Script ninjaScript) at NinjaTrader.Gui.NinjaScript.IndicatorRenderBase.Co pyTo(NinjaScript ninjaScript) at NinjaTrader.NinjaScript.NinjaScript.Clone()

      But I really neither have any usage of DrawHorizontalGridLines property not have some special usage of anything in SetDefaults state (just setting of some default indicator properties values).

      I don't have any explicit serializer for my class, just [XmlElement] or [XmlIgnore] attributes for all public properties which are of course public for both get and set.

      Comment


        #4
        I see, this is quite similar issue as it was stated by Harry in http://ninjatrader.com/support/forum...ad.php?t=93074

        Comment


          #5
          Hello ku8az,

          Thank you for your patience.

          Would you be able to provide the details below?

          Can you provide the full error message from your indicator when you connect to your provider?

          How are you serializing the property? Can you provide an example of the property as well as the custom converter used?

          I look forward to your response.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by tkaboris, Today, 08:01 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by Lumbeezl, 01-11-2022, 06:50 PM
          31 responses
          817 views
          1 like
          Last Post NinjaTrader_Adrian  
          Started by xiinteractive, 04-09-2024, 08:08 AM
          5 responses
          15 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by swestendorf, Today, 11:14 AM
          2 responses
          6 views
          0 likes
          Last Post NinjaTrader_Kimberly  
          Started by Mupulen, Today, 11:26 AM
          0 responses
          7 views
          0 likes
          Last Post Mupulen
          by Mupulen
           
          Working...
          X