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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          55 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          142 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          160 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          96 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          276 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X