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

DataSeries White Paper

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

    DataSeries White Paper

    I'm trying to dig deeper into the DataSeries feature... What is it? Is a some sort of mutable object that I can stuff anything into? It seems like a powerful container, but the documentation on it:



    is lacking in description, details and usage.

    I see a "Set()" method... Is this just a wrapper around an array, Custom Object?

    Thank You,
    Robert

    #2
    Originally posted by RobVig View Post
    I'm trying to dig deeper into the DataSeries feature... What is it? Is a some sort of mutable object that I can stuff anything into? It seems like a powerful container, but the documentation on it:



    is lacking in description, details and usage.

    I see a "Set()" method... Is this just a wrapper around an array, Custom Object?

    Thank You,
    Robert
    That's odd... I was able to use DataSeries for my needs based off the example.

    You might be thinking too hard about this. It's just an easy thing to access and pass around with other NT things and it plays nicely without having to dig deeper.

    Each time OnBarUpdate is called and Set is applied - it behaves like everything else in NT.

    Comment


      #3
      Hmmm... Still not clear on what objects I can stuff into it. How to store them; how to retrieve them... I'm glad it makes sense to you.

      Comment


        #4
        Originally posted by RobVig View Post
        Hmmm... Still not clear on what objects I can stuff into it. How to store them; how to retrieve them... I'm glad it makes sense to you.
        Good for storing #s.. doubles.. any computation...

        Like in the example:

        Code:
        protected override void OnBarUpdate()
        {
            // Calculate the range of the current bar and set the value
            myDataSeries.Set(High - Low);
         
            // Print the current 10 period SMA of range
            Print("Value is " + SMA(myDataSeries, 10)[0]);
        }
        If you have some super duper computation on EachBarUpdate that you need to store , you can store it. High-Low is "pretty weak"... but serves as an example.

        So you can take your super duper computation on EachBarUpdate and easily apply an SMA, EMA, WMA, or any other indicator that accepts an input.

        Does this explanation help?

        ----
        Edit :

        also in the documentation:

        Definition
        A DataSeries is a special type of data structure that holds a series of double values and always contains the same number of elements as bars in a chart. If you have 200 bars loaded in your chart with a moving average plotted, the moving average itself holds a DataSeries object with 200 historical values of data, one for each bar. DataSeries objects can be used as input data for all indicator methods. The DataSeries class implements the IDataSeries interface.
        Last edited by sledge; 06-01-2016, 10:40 PM.

        Comment


          #5
          Hello RobVig,

          Thank you for your post.

          It is a series of objects synced to the number of bars in a bars object. Objects can be double, int, bool, etc. You can visit the following link for information on the various Series types: http://ninjatrader.com/support/helpG...properties.htm
          The Series types are DataSeries, IntSeries, BoolSeries, DateTimeSeries, etc.

          As each object is synced to a bars object it will contain up to the number of bars for the bars object. You can store items based on the BarsAgo value. For example:
          Code:
          MyDataSeries[0] = Close[0]; // set the current value of the DataSeries to the current value of the Close
          You would call it using BarsAgo as well. For example:
          Code:
          Print(MyDataSeries[5]); // print the value of the data series from 5 bars ago.

          Comment


            #6
            Hi Patrick and Sledge!

            Thank you for your response's. Now it's starting to make sense.
            Regarding Patrick's code: MyDataSeries[0] = Close[0]
            Can I continue to add to MyDataSeries? Ex: MyDataSeries[0] = Open[0] without overwriting the initial Close[0]?

            Would this code be the equivalent:

            double todaysClose = Close[0]; ????

            Why would I choose a DataSeries object over a simple typed variable?

            DataSeries' look like an array to me except the "[ ]" are used to designate time instead of a piece of memory... Make sense? What I'm hoping to do (and could with traditional C# patterns) is create a custom object that represent various objects. (OOP 101)
            Ex:
            class TradingDay {
            public double Open { get; set; }
            public double High { get; set; }
            public double Low { get; set; }
            public double Close { get; set; }
            public double Volume { get; set; }
            public double HotIndicatorVal { get; set; }
            List<double> ...
            }

            That said... If NTD already has something like this "out of the box" that I can iterate through... Then I won't write it...

            Thanks again!
            Robert
            Last edited by RobVig; 06-02-2016, 03:57 PM.

            Comment


              #7
              Originally posted by sledge View Post
              You might be thinking too hard about this. It's just an easy thing to access and pass around with other NT things and it plays nicely without having to dig deeper.

              Each time OnBarUpdate is called and Set is applied - it behaves like everything else in NT.
              It helps to think of a DataSeries (or any of the xxxSeries classes in NinjaScript) as 1) an array that automatically grows by one every time a bar closes and as 2) an array that is accessed backwards.

              #1 is kinda obvious. That is Open/Close/High/Low and others are DataSeries that grow by one element at the close of each bar.

              #2 is the secret sauce. A regular array means that Arr[0] is accessing the first element of the array. Think carefully, accessing Arr[0] is effectively accessing the oldest element, especially when you are incrementally adding new elements to the array. This is the normal traditional way of learning about an array.

              But #2 means that, in an xxxSeries based "array", the element at Arr[0] is not the oldest element in the array (er, I mean, DataSeries), but Arr[0] accesses the newest element in the array -- which in NinjaScript is always associated with the most recently closed bar.

              That is, if you have 255 elements in a regular array called Arr then:
              Arr[0] is the oldest element, or first element, added to the array.
              Arr[254] is the most recent element, or last element, added to the array.

              If you have 255 elements in a DataSeries called Arr, this means,
              Arr[0] is the most recent data element (aka, associated with the most recently closed bar).
              Arr[254] is the oldest data element (aka, the bar 254 bars ago, to the left)

              See that? The access (from the perspective of age) is "backwards".

              Also, in line with the names "IntSeries" and "BoolSeries", the name "DataSeries" is a bit of misnomer. The "DataSeries" class should, arguably, have been named "DoubleSeries", since the type of value it contains is a double.
              Last edited by bltdavid; 06-03-2016, 08:27 PM.

              Comment


                #8
                Originally posted by RobVig View Post
                That said... If NTD already has something like this
                What is "NTD"?

                Comment


                  #9
                  Originally posted by bltdavid View Post
                  What is "NTD"?
                  NinjaTraDer. I don't understand it!

                  There's another abbreviation that irritates me.

                  Comment


                    #10
                    Originally posted by sledge View Post
                    NinjaTraDer. I don't understand it!

                    There's another abbreviation that irritates me.
                    Yah mon, I know, I totally agree!

                    I thought NTD perhaps meant NinjaTrader Development.

                    The OP needs to just say NinjaScript -- there is no common abbreviation, except maybe NS, but that's not very common, in my view.

                    "NinjaScript" is the name of the C# .NET framework made available to users of the NinjaTrader application.

                    For NinjaTrader, NT is the generally accepted abbreviation around here, or NT7 or NT8, if you need to distinguish between the two.
                    Last edited by bltdavid; 06-02-2016, 09:32 PM.

                    Comment


                      #11
                      Originally posted by bltdavid View Post
                      Yah mon, I know, I totally agree!

                      I thought NTD perhaps meant NinjaTrader Development.

                      .
                      That might even make more sense!

                      Comment


                        #12
                        Originally posted by RobVig View Post
                        class TradingDay {
                        public double Open { get; set; }
                        public double High { get; set; }
                        public double Low { get; set; }
                        public double Close { get; set; }
                        public double Volume { get; set; }
                        public double HotIndicatorVal { get; set; }
                        List<double> ...
                        }
                        Robert
                        Hello RobVig,

                        Thank you for your response.

                        You could simply do that with DataSeries objects. As bltdavid mentioned, there is a slot available for the data on each bar update.

                        You would choose a DataSeries as you could hold historical values or values across the entire chart for each bar on the chart. A double would only have one value and would be overwritten each type you assign it.

                        Comment


                          #13
                          @sledge & @bltdavid - (kindly) Gentlemen, can you please move the "NTD" debate to another discussion? I would like my thread to stay on topic. Thank You ;>
                          Last edited by RobVig; 06-03-2016, 08:46 AM.

                          Comment


                            #14
                            @sledge & @bltdavid - I am new to NinjaTrader. I thought NTD was an abbreviation for
                            NinjaTraDer.

                            (kindly) Gentlemen, can you please move the "NTD" debate to another discussion? I would like my thread to stay on topic. Thank You ;>

                            Comment


                              #15
                              Originally posted by RobVig View Post
                              @sledge & @bltdavid - I am new to NinjaTrader. I thought NTD was an abbreviation for NinjaTraDer.
                              Yes, we figured that. Quite alright. Sorta.

                              Originally posted by RobVig View Post
                              (kindly) Gentlemen, can you please move the "NTD" debate to another discussion? I would like my thread to stay on topic. Thank You ;>
                              Sure. Discussion over.

                              You're welcome.

                              But your overall knowledge profited from this "debate", didn't it?

                              (Kindly) I mean, as you implied, certain basic knowledge is lacking by people new to NinjaTrader, and new knowledge is passed on or picked up by new folks in many different ways. Hopefully, your love affair with NT is just starting, while ours has been in full bloom for quite awhile. Welcome aboard, mate, enjoy the journey!

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by cre8able, Today, 03:20 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post cre8able  
                              Started by Fran888, 02-16-2024, 10:48 AM
                              3 responses
                              47 views
                              0 likes
                              Last Post Sam2515
                              by Sam2515
                               
                              Started by martin70, 03-24-2023, 04:58 AM
                              15 responses
                              114 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by The_Sec, Today, 02:29 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              2 responses
                              31 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X