Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

XML Serialization during strategy run...?

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

    XML Serialization during strategy run...?

    Hi,

    I just turned on XML serialization for some of my objects (using XmlSerializer), because I'm trying to feed some run-time data into a different program. This worked fine in strategy analyzer, but when I tried to run real time... NT popped up a mysterious message box warning me serialization failed while writing to database, etc, etc. (I'll try to screen capture next time.)

    I'm guessing what's happening is that NinjaTrader uses the same .NET classes to serialize our strategy state...? And my custom-written attributes, etc... are some how interfering with that process? Can I get a confirmation that's the case from someone (Dierk?)?

    If so, I guess the solution is to probably make the fields that are tied to my serializer private.. right?

    #2
    Oh, here's the actual message (captured in log):

    3/12/2009 8:48:35 AM Default Failed to execute DB job 'StrategyUpdateJob': There was an error reflecting type 'NinjaTrader.Strategy.ProtectDownMulti'.: There was an error reflecting field 'states'.: There was an error reflecting type 'Chon.Utilities.SimpleState'.: Cannot serialize member 'Chon.Utilities.SimpleState.config' of type 'Chon.Utilities.SimpleConfiguration', see inner exception for more details.: Chon.Utilities.SimpleConfiguration cannot be serialized because it does not have a parameterless constructor.

    ... simple enough, I'll just add the parameterless constructor.

    Comment


      #3
      Here's the next error message in the series that I can't get rid of:

      3/12/2009 9:11:00 AM Default Failed to execute DB job 'StrategyUpdateJob': There was an error reflecting type 'NinjaTrader.Strategy.ProtectDownMulti'.: There was an error reflecting field 'states'.: There was an error reflecting type 'Chon.Utilities.SimpleState'.: There was an error reflecting field 'longOrder'.: There was an error reflecting type 'Chon.Utilities.SimpleOrder'.: Cannot serialize member 'Chon.Utilities.SimpleOrder.Order' of type 'NinjaTrader.Cbi.IOrder', see inner exception for more details.: Cannot serialize member Chon.Utilities.SimpleOrder.Order of type NinjaTrader.Cbi.IOrder because it is an interface.

      ... I think I just need to find a way for it not to try to serialize "states". I assume declaring it private will do the trick.

      Comment


        #4
        Glad you figured it out.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Unfortunately this is beyond the scope we could provide support for.

          Hints: As you experienced there would be multiple issues needed to be considered with XML serialization:
          - parameter less constructor or no constructor at all
          - marking public properties as non-serializable (XmlIgnore)
          - many more...

          Please consult the MS doc for a full list

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          582 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          338 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          552 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X