Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Serializing indicators

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

    #16
    Thanks,

    problem was here:

    public DataSeries RangeHigh;

    As you found but the reason is the public. This needs to be private as if its Public it gets added to be serialized (Like a property) and since you have no get or set accessor this process fails.

    Private will work here if you need to access this DataSeries from external then you need to use this guide:

    BrettNinjaTrader Product Management

    Comment


      #17
      OK, thanks Brett, I'll give that a shot.
      Last edited by kenb2004; 07-19-2012, 03:45 PM.

      Comment


        #18
        Originally posted by kenb2004 View Post

        #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
        And that is your problem. If you want to access a DataSeries from outside a class, the correct method is to access it by defining public properties to a private data store, not by declaring the DataSeries itself as public.

        Here is another thread that discusses that same issue: http://www.ninjatrader.com/support/f...110#post293110

        Comment


          #19
          So, if public DataSeries RangeHigh;
          is changed to private DataSeries RangeHigh;
          Then what exactly should the code in properties be to access this DataSeries outside the class?
          Thanks

          Comment


            #20
            The sample on how to do that is here:

            BrettNinjaTrader Product Management

            Comment


              #21
              Brett

              I see how this works for a BoolSeries and Plots, but how do you change it for a DataSeries?
              Thanks

              // From SampleBoolSeries
              [Browsable(false)]
              [XmlIgnore()]
              public BoolSeries BullIndication
              {
              get { return bullIndication; } }

              // From SampleCustomDataSeries
              [Browsable(false)]
              [XmlIgnore()]
              public DataSeries AvgR
              {
              get { return Values[0]; }
              }

              Comment


                #22
                Code:
                [Browsable(false)]
                        [XmlIgnore()]
                        public DataSeries BullIndication
                        {
                            get { return bullIndication; }   
                        }
                then


                Code:
                private DataSeries bullIndication;
                in the variables section with a lowecase b and finally the standard dataseries sync in initialize.

                Code:
                bullIndication            = new DataSeries(this);
                BrettNinjaTrader Product Management

                Comment


                  #23
                  Thanks Brett

                  So with a DataSeries there is no reference to Value, like with a plot, int or double?

                  Comment


                    #24
                    right, since you don't set it in the GUI nor do you want it visible there so you don't want to take a returned value from the GUI to set it.

                    -Brett
                    BrettNinjaTrader Product Management

                    Comment


                      #25
                      Thanks again

                      Comment


                        #26
                        Is this the proper way to use the current value for the Indicator's DataSeries in a Strategy? Or does it need to stay a DataSeries?

                        Strategy
                        protected
                        overridevoid OnBarUpdate()
                        double myDataSeriesValue = SampleCustomDataSeries().MyDataSeries[0];

                        How would you keep it as a DataSeries and not a double?
                        MySeries = SampleCustomDataSeries().MyDataSeries[0];
                        Last edited by kenb2004; 07-23-2012, 01:07 PM.

                        Comment


                          #27
                          Not sure I understand what you ave going on there. No need to set it as a double if you dont want too.

                          Just access this directly like you do an indicator.

                          SampleCustomDataSeries().MyDataSeries[0];


                          Just use that right in the spots you want to access the calculation.

                          -Brett
                          BrettNinjaTrader Product Management

                          Comment


                            #28
                            I had the same Serializing problem...

                            i resolve it like in then example

                            [Browsable(false)] [XmlIgnore()]
                            public DataSeries BullIndication
                            { get { return bullIndication; } }


                            then

                            Code:
                            private DataSeries bullIndication;

                            Code:
                            bullIndication = new DataSeries(this);


                            When i recall the above indicator ...i set in a strategy the folllowing instruction:


                            SampleCustomDataSeries().Bullindicator[0];

                            Is correct?

                            In your example seem to be following :

                            SampleCustomDataSeries().bullindicator[0]; >>>>(bullindicator declare in Initialize)




                            Last edited by turbofib; 02-21-2014, 04:41 PM.

                            Comment


                              #29
                              Hello Turbofib,

                              Yes, this is the correct method for getting the data series value that you want
                              Cal H.NinjaTrader Customer Service

                              Comment


                                #30
                                In the example I posted:

                                code:
                                bullIndication private DataSeries;

                                code:
                                bullIndication = new DataSeries (this);


                                bullindication how is it used?

                                when I use Bullindication

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by argusthome, 03-08-2026, 10:06 AM
                                0 responses
                                88 views
                                0 likes
                                Last Post argusthome  
                                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                                0 responses
                                48 views
                                0 likes
                                Last Post NabilKhattabi  
                                Started by Deep42, 03-06-2026, 12:28 AM
                                0 responses
                                30 views
                                0 likes
                                Last Post Deep42
                                by Deep42
                                 
                                Started by TheRealMorford, 03-05-2026, 06:15 PM
                                0 responses
                                34 views
                                0 likes
                                Last Post TheRealMorford  
                                Started by Mindset, 02-28-2026, 06:16 AM
                                0 responses
                                68 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Working...
                                X