Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with DateTime Serialization

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

    Problem with DateTime Serialization

    To allow for a user defined entry of a DateTime variable, I coded

    #region Variables
    ...
    private DateTime publicHoliday0 = new DateTime (2009,01,19);
    ...

    #region Properties
    ....
    public DateTime PublicHoliday0
    {
    get { return publicHoliday0;}
    set { publicHoliday0 = value;}
    }

    Problem: If the user sets a new value for PublicHoliday0, this value is not saved with the workspace, so after a restart of NinjaTrader, the default setting (2009,10,19) reappears.

    With NT 6.5. there were no problems, With NT 7.0 I used this identical code for several indicators. For some indicators it works, for others it does not, so I admit being confused.

    #2
    Hi Harry,

    I am testing this on my end to try to reproduce, and will respond shortly.
    TimNinjaTrader Customer Service

    Comment


      #3
      and to add TimeSpan by default dont get serialized in xml.


      pls make some provisions to serialize the same.

      regards

      Comment


        #4
        HI Harry,

        I have not been able to reproduce this, unfortunately. Each time, it seems to save with the workspace ok.

        If you have a script for me to test, I'd be happy to do so.
        TimNinjaTrader Customer Service

        Comment


          #5
          I am aware that TimeSpan cannot be serialized and had implemented this with NT 6.5, but here I am talking about DateTime objects.

          Originally posted by bukkan View Post
          and to add TimeSpan by default dont get serialized in xml.


          pls make some provisions to serialize the same.

          regards

          Comment


            #6
            Two indicators for testing

            Hi Tim,

            here is a test file with two indicators. Both allow to set a date via indicator dialogue. If you put them both on a chart, then modify the default date (I simply changed the year to 2007) and then save the workspace with the chart, one of the indicators will store the new date, the other one will not.

            I could not find out the reason!
            Attached Files

            Comment


              #7
              Hi Harry,

              Looks like you explicitly override the default serialization with [XmlIgnore]

              Removing that line from properties should do it.
              TimNinjaTrader Customer Service

              Comment


                #8
                Hi Tim,

                thanks very much for your help, I should have seen that. I just copied this unintentionally from another section, when writing the code. My fault, of course, but much the better, because this is the best of all options -> problem solved immediately. So thanks again.

                Comment


                  #9
                  Hi Harry,

                  Just glad to hear that did it!
                  TimNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  597 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  343 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
                  556 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  555 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X