Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Serializing indicators

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

    Serializing indicators

    I recently tried to save my workspace and got the error message:
    Indicator'NinjaTrader.Indicator.Indicator_1' could not be serialized. Please refer help for more information on serializing indicators.

    When I searched Help I got the message "No Topics founds".

    How do I resolved this issue?

    Thanks

    #2
    Hello kenb2004,
    TimeSpan, Color etc cannot be serialized. This is a limitation withing Windows. If your indicator contains such properties then the workspace wont get saved.

    You can however save/convert the parameters as string/int and then reconvert it or set the XmlIgnore attribute to false so that it does not get serialized at all.

    Please refer to this post which further illustrates it
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thanks Joydeep

      SampleColorInput_NT7.zip

      Is there a list of these sample files somewhere? I asked this before and I was told to look at the reference samples, but this sample is not there.

      Thanks

      Comment


        #4
        Hello kenb2004,
        Unfortunately there are no comprehensive list. You can however refer to this this thread



        Also a sample code for serializing the TimeSpan will be

        Code:
        [Description("")]
        [GridCategory("Parameters")]
        [XmlIgnore()]
        public TimeSpan TradeStart
        {
        get { return _TradeStart; }
        set { _TradeStart = value; }
        }
        
        [Browsable(false)]
        public long TradeStartSerialize
        {
        get { return _TradeStart.Ticks; }
        set { _TradeStart = new TimeSpan(value); }
        }

        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          [Description("Reference sample showing how to create user definable color inputs.")]

          How about if you do not want the color to be user definable?

          DrawRectangle("rectangle", true, 0, High[0], 5, Low[5], Color.Red, Color.Blue, 10);

          The use of these colors have no properties, so how would you
          "set the XmlIgnore attribute to false so that it does not get serialized at all."

          thanks

          Comment


            #6
            Hello kenb2004,
            If you do not want the colors to be user defined then you can simply hard code it like
            Code:
            DrawRectangle("rectangle", true, 0, High[0], 5, Low[5], Color.Red, Color.Blue, 10);

            If you hard code it you dont have any property and thus you dont have to use the XmlIgnore() attribute.

            XmlIgnore only comes to play if you have a Color (or any non serializable value) as a Property.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              Joydeep

              Thank you. I resolved the issue by commenting out code out to see when the problem went away. What I found was that the DataSeries that I create from doubles created the Serialize problem. I created them to access the Indicator from a strategy.

              The DataSeries were created as per NinjaTrader Help Guide declaring them in variables, then "new this" in Initialize, and then Set. to doubles in OnBarUpdate as their values.

              I did not see any mention of "Properties". Does something need to go in "Properties" to serialize the DataSeries?

              thanks

              Comment


                #8
                Hello,

                Data Series objects by themselves don't need any custom code for serialization.

                I'm surprised this would resolve. What is the exact line you commented out? Can you remove the comment as well to make double sure this is the problem line.


                -Brett
                BrettNinjaTrader Product Management

                Comment


                  #9

                  #region
                  Variables
                  public DataSeries RangeHigh;

                  protectedoverridevoid Initialize()
                  RangeHigh = new DataSeries(this);

                  protectedoverridevoid OnBarUpdate()
                  _rangehigh = High[CurrentBar - highBar];
                  RangeHigh.Set(_rangehigh);

                  Bret

                  I uncommented these 3 lines and the serialize error came back. Then I commented them out 1 by 1 starting with the OnBarUpdate and ending with the variable. OnBarUpdate out - error, Initialize out - error, variable out - no error.

                  I need these DataSeries to DrawRegion, even though I don't understand why you need 1 double and 1 series, or 2 series. Why not 2 doubles?

                  Thanks
                  Last edited by kenb2004; 07-19-2012, 02:16 PM.

                  Comment


                    #10
                    Hello,

                    Just the code alone shouldn't cause problem.

                    I suspect you have something in Properties section colliding(might have the same name or something)

                    Can you paste your whole properties section as well please. You can send it into support at ninjatrader dot com if you prefer.

                    -Brett
                    BrettNinjaTrader Product Management

                    Comment


                      #11
                      The lowercase rangehigh is a DataSeries for a plot

                      Would this create a problem? I don't know how to use the code box and my Properties won't submit. Maybe the message box has a limitation.

                      Comment


                        #12
                        Can you send it to support at ninjatrader dot com if still questions but think you just found the problem. What you specify would cause problems here.

                        -Brett
                        BrettNinjaTrader Product Management

                        Comment


                          #13
                          [Browsable(false)]
                          [XmlIgnore()]
                          public DataSeries rangehigh
                          {
                          get { return Values[1]; } }

                          If C# is case sensitive, how would this be the problem? And if so how would you recommend resolving it?

                          Thanks

                          Comment


                            #14
                            I need to see full code but I think you have some duplication somewhere I can't see.If there are different capitalization then it should be ok. I thought you have _rangeHigh as a DataSeries and as a double but it was rangehigh you were talking about.

                            Where is the property then for RangeHigh? I guess I just need to look at the code.

                            -Brett
                            BrettNinjaTrader Product Management

                            Comment


                              #15
                              I just sent you the indicator to support.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              77 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              45 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              27 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              32 views
                              0 likes
                              Last Post TheRealMorford  
                              Started by Mindset, 02-28-2026, 06:16 AM
                              0 responses
                              64 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Working...
                              X