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

Serialization Error

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

    Serialization Error

    I've written an indicator that compiles and runs clean however when I try to save it in a workspace I get a Serialization error that says to look up Serialization in the help.

    1) I dont see anything about serialization in the help.

    2) What could possibly be causing this? How would you debug something like this?

    thanks,
    shawnj

    #2
    Hi shawnj,

    Please consider repairing your database with those instructions below -

    1. Disconnect NinjaTrader from any open connections via File > Disconnect

    2. From the NinjaTrader Control Center window select the menu Tools > Options

    3. Select the "Misc" tab

    4. Press the "Repair DB" button

    5. Press the "OK" button

    Then bring up a chart and try to save this with your indicator applied to a workspace and see if the issue persists.

    Happy Thanksgiving!
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Always with the Repair DB <g>. Is NT's database that fragile or is this what the new guy is taught to tell anyone who writes in with a problem <GG>.

      Well, repairing the database did not fix the problem.

      Here is a screenshot of the error message.

      Again my original questions:

      1) as per the error dialog, where is the help for more info on serializing indicators.

      2) what could be causing this (other than the database) and how can I troubleshoot it?

      Logic would dictate, If the code compiles, we should not see an error like this.
      Attached Files

      Comment


        #4
        shawnj;

        I recall getting the same errors a while back. After much backtracking on the code my issue was with "Exposing" DataSeries and BoolSeries. Basically everything that is not a Plot needs to follow the exact procedure in the sample file ("Exposing Bool Series" i think) if you want other Indicators and Strategies to have access to them. There is an Indicator file that creates the series and a Strategy file that receives the series in the Zip Package. The reason I bring that up is that it took me a while to realize there were two files .

        I do not know if your code requires the above but if it does I would start there.

        T

        Comment


          #5
          Thanks T.

          In case this might help someone else:
          After a bunch of blocking out chunks of code and trying to serialize again, I've roughly zeroed in on the problem. I say roughly because I tried to write a stripped down indicator that would duplicate/document the exact problem and I have not been unable to find the exact combination that is causing it .

          However, this is how I "fixed" my indicator. This indicator has an embedded class. I wrote the constructor for that class to take a set of parameters. Adding a default constuctor (no parameters) "fixed" it.

          I've now added a new step to my indicator development workflow:
          -After a few hundred clean compiles, test the serialization .

          thanks,
          shawnj
          Last edited by shawnj; 11-27-2008, 10:09 AM.

          Comment


            #6
            I've bumped into this serialization problem while saving templates several times now, so I figured if I posted a solution reference, I can google and find it quicker next time.

            Basically any indicator class variable that you want to make public should be declared in the Properties region similar to how Plots are exposed. For Ninja series variables, the format is:

            [Browsable(false)]
            [XmlIgnore()]
            public DataSeries Variable
            {
            get { return dsVariable; }
            }

            where "dsVariable" is a private DataSeries variable used in the indicator and "Variable" is the public DataSeries that can be accessed by other indicators and strategies. The above format also works for BoolSeries variables. For other C# data types, the format in the Properties region is:

            [Browsable(false)]
            [XmlIgnore()]
            public double DoubleVariable
            {
            get { Update(); return doubleVariable; }
            }

            where "doubleVariable" is a private double variable used in the indicator and "DoubleVariable" is the public variable that can be accessed in other indicators and strategies. The Update method is called to force Ninja to update all the variable values before returning the value.

            The reference sample TajTrades mentioned (SampleBoolSeries) has additional information in a complete indicator and can be found here:



            Regards,

            David

            Comment


              #7
              dbw451 (and others),

              Thank you very much for taking the time to give such a detailed advice. Just to let you know that helped me to solve my Serialization problem. This advice must be included in the Help file.

              Thanks

              Comment


                #8
                astra,

                You're welcome and thanks for the feedback. I suggest that you pay-it-forward. If you solve a Ninja issue or can clarify a solution in the future that you think would benefit others, take a few minutes and document your issue and solution for the benefit of the Ninja community.

                Best Regards,

                David
                dbw451

                Comment


                  #9
                  indicator can't be serialized

                  I'm having the same problem: I have a simple indicator with 2 public BoolSeries, and when I try to save a chart template with this indicator on it the error message pops up about

                  "indicator can't be serialized, refer [to non-existent] help on serializing indicators"

                  The error is related to my 2 public boolseries objects, because if I remove them it doesn't give the error. Both boolseries are declared in the variables, initialize, and properties sections according to the examples. The boolseries values are accessible from other indicators even though they generate the serialization error when I try to save a chart template.

                  Any more ideas?

                  Comment


                    #10
                    Please see this reference sample on how to expose them properly: http://www.ninjatrader-support2.com/...ead.php?t=4991
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      The BoolSeries used in your code should be declared as private and only the BoolSeries declared in the Properties section should be public. Whenever I experience the problem, it's because I declared public variables in the Variables section.

                      Regards,

                      David
                      dbw451

                      Comment


                        #12
                        thanks!

                        Thanks dbw, that was it. I had declared the boolseries as public in the variables. I changed it to private and issue is resolved! NT please put dbw on the payroll.

                        Comment


                          #13
                          Serialization Errors

                          When backing up my workspace, I sometimes get the message indicator XYZ cannot be serialized. Today I had the problem several times, and it just is a game of try and error.

                          The indicator that causes the problem does not include any TimeSeries other than standard plots, so there is no particular code that could cause the problem. I also downloaded and read the sample files referred to by Josh below, but I cannot find anything wrong at all.

                          The error occurs when the indicator is applied to one of the charts and is definitely not reproducible. Sometimes the backup works out smoothly and sometimes I get the error message.

                          Is this one of the the NT database demons at work, or is there anything that I can do to avoid this? Thank you for your help.

                          Comment


                            #14
                            Harry, are those indicators embedded in any workspace / template files? Then please try creating a fresh set of files and recheck the issue.
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              yep Harry, this is one of the NT demons at work
                              i also know this behavior -
                              Sometimes the "save workplace" works out smoothly and sometimes I get the error message+ its definitely not reproducible.
                              its not often - and its definitely not a fact of a special indicator or a bad coded indie.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by andrewtrades, Today, 04:57 PM
                              1 response
                              4 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by chbruno, Today, 04:10 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post chbruno
                              by chbruno
                               
                              Started by josh18955, 03-25-2023, 11:16 AM
                              6 responses
                              436 views
                              0 likes
                              Last Post Delerium  
                              Started by FAQtrader, Today, 03:35 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post FAQtrader  
                              Started by rocketman7, Today, 09:41 AM
                              5 responses
                              19 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X