Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unable to deserialize user data: There is an error in XML document

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

    Unable to deserialize user data: There is an error in XML document

    Hello,

    I am developing some automated strategies on my computer that my father then runs on his computer.

    Yesterday I changed some user defined inputs in the Properties section, and everything is OK on my side, NT8 runs perfectly.

    However, when I updated the strategies on my dad's computer, NT started to crash before it can even open.

    I suspect it may be a serialization problem, as mentioned here: https://ninjatrader.com/support/foru...-inputs?t=4977

    But I'm not sure since everything runs perfectly on my computer...

    Here is the code of my new properties:

    [NinjaScriptProperty]
    [TypeConverter(typeof(MyMethods.PivotPeriodCollecti onConverter))]
    [PropertyEditor("NinjaTrader.Gui.Tools.StringStanda rdValuesEditorKey")]
    [Display(Name="Pivot Period:", Order=15, GroupName="Parameters")]
    public PivotRange PivotPeriod
    {
    get { return myPivot; }
    set { myPivot = value; }
    }

    And the related type converter:

    public class PivotPeriodCollectionConverter: StringConverter
    {
    /// <summary>
    /// This class supports a standard set of values that can be picked from a list.
    /// </summary>
    public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
    {
    return true;
    }

    /// <summary>
    /// Return true if the destinationType parameter is the same type as the class that uses this type converter.
    /// </summary>
    public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
    {
    if (destinationType == typeof(PivotRange))
    return true;
    return base.CanConvertTo(context, destinationType);
    }

    /// <summary>
    /// Ensure that the destinationType parameter is a String and that the value is the same type as the class that uses this type converter.
    /// Return a string representation of the value object.
    /// </summary>
    public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
    {
    if (destinationType == typeof(string) && value is PivotRange)
    return value.ToString();
    return base.ConvertTo(context, culture, value, destinationType);
    }

    /// <summary>
    /// Parse the property value and convert it to the type of the class that uses this type converter.
    /// </summary>
    public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
    {
    if (value is string)
    {
    if (value == "Daily")
    return PivotRange.Daily;
    else if (value == "Weekly")
    return PivotRange.Weekly;
    }
    return base.ConvertFrom(context, culture, value);
    }

    /// <summary>
    /// Return a StandardValuesCollection filled with the standard values.
    /// </summary>
    public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
    {
    return new StandardValuesCollection(new string[] {"Daily", "Weekly"});
    }
    }

    I also added this property :

    [NinjaScriptProperty]
    [Display(Name="MA trigger : ", Order=4, GroupName="Parameters")]
    public MovingAverageEnum MovingAverageType
    {
    get { return movingAverageType; }
    set { movingAverageType = value; }
    }

    And the enum:

    public enum MovingAverageEnum
    {
    FastEma,
    SlowSma
    }

    Do you guys think these properties need to be serialized, or xml ignored ?

    I attached 2 log files. They state the following error: Strategy '154181414': unable to deserialize user data: There is an error in XML document (93, 4).

    Any help would be appreciated,
    Thank you

    Alex
    Attached Files

    #2
    Hello alexismailhot,

    Thank you for the post.

    Yes, Serialization and Deserialization problems can happen and in this case, this is a deserialization problem. This may be an existing template or workspace trying to load incorrect settings for the modified script.

    Before continuing further, I would likely suggest doing a simple test to see if either of these items are at fault. You can first try to remove the templates for the item and start the platform if that does not work try temporarily removing the workspaces. In the case it starts without either template or workspace we could say that is the cause, otherwise, it may be related to something else happening.

    The templates can be found in the folder: Documents\NinjaTrader 8\templates\Strategy
    and workspaces in the folder: Documents\NinjaTrader 8\workspaces

    You can move the .xml files in these folders to a new folder on your desktop temporarily and then test. Once you know the result they can be moved back to where they were or leave the file excluded if it was the problem.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      You're right, it was the workspaces that were at fault.
      I removed them and everything came back to normal.

      Thank you as always for the amazing support!

      Alex

      Comment


        #4
        Hello,

        Unfortunately it seems like the problem persisted after all. It worked fine for a day, but now the errors are back.

        I attached the most recent log file.
        According to the log file, it seems like the errors appear right after the "Restoring workspace 'Untitled'...".

        I also get this error: "Unhandled exception: Object reference not set to an instance of an object."

        It's weird, because those errors only show up on my dad's computer, everything is fine on my computer (with the same code).

        Do you guys have an idea of what I should do next?

        Thank you,
        Alex
        Attached Files

        Comment


          #5
          Hello alexismailhot,

          Thank you for the reply.

          In this situation, I would suggest further testing what is causing the problem with this script by reducing its code to find what controls the problem.

          You originally noted that you changed some inputs and then the problem started. A good test may be to take just that code and place it in a new script then re test if the new script also has the error. If so, we could review that sample together to see if I get the error to further review it.

          Have you tried extracting the code at this point?


          I look forward to being of further assistance.

          JesseNinjaTrader Customer Service

          Comment


            #6
            Hello Jesse,

            I tried to comment out the new inputs and the errors persisted. Then, I commented out the whole strategies (all lines of code) and the problem is still there...

            It seems like the problems may not be code-related... Or maybe the code caused the problem at first, and now the problem persists ?! What do you think?

            Thanks,
            Alex

            Comment


              #7
              do you have the code I can check it for you
              I looked at the log but I need to check the lines
              numbers

              Comment


                #8
                I found the problem.
                I simply needed to reset the database... I found the answer on this post: https://ninjatrader.com/support/foru...lize-user-data

                Thanks for your help!
                Alex

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by love2code2trade, Yesterday, 01:45 PM
                4 responses
                28 views
                0 likes
                Last Post love2code2trade  
                Started by funk10101, Today, 09:43 PM
                0 responses
                7 views
                0 likes
                Last Post funk10101  
                Started by pkefal, 04-11-2024, 07:39 AM
                11 responses
                37 views
                0 likes
                Last Post jeronymite  
                Started by bill2023, Yesterday, 08:51 AM
                8 responses
                44 views
                0 likes
                Last Post bill2023  
                Started by yertle, Today, 08:38 AM
                6 responses
                26 views
                0 likes
                Last Post ryjoga
                by ryjoga
                 
                Working...
                X