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 in indicator restricted to type double

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

    DataSeries in indicator restricted to type double

    I'd like to be able to put values into an indicator's dataseries using types that are not plain doubles.

    In fact sometimes I'd like to use a class of my own.

    I want to use this functionality for passing more data to the Plot method, or to other indicators or strategies.

    Is there the chance of this feature being integrated into NT8?

    Thanks

    #2
    You have the option to expose other series which are not plots and pass information from one indicator to another.

    Does this accomplish some of what you're looking for?

    MatthewNinjaTrader Product Management

    Comment


      #3
      Yes, I assume that will work although I won't have a go at programming it at this point since I had no idea of its existence and used a work-around to accomplish what I needed to do. Either I missed it or you should put some references in the DataSeries Help file to point people towards that reference above.

      Hopefully when it comes back on the radar, I'll be able to implement something really good using this functionality.

      Thanks

      Comment


        #4
        I'm now attempting to build an indicator where I have a dataseries that contains lists.

        The example you pointed to shows how to use BoolSeries but it doesn't show how to create a new IDataSeries implementation like I need for List<>.

        Do I need to implement IDataSeries directly? If so, I get an error:

        Code:
        'NinjaTrader.Indicator.PermaCodeSR005.ListSeries' does not implement interface member 'NinjaTrader.Data.IDataSeries.this[int]'.
         'System.Collections.Generic.List<NinjaTrader.Indicator.PermaCodeSR005.SRLevel>.this[int]' 
        cannot implement 'NinjaTrader.Data.IDataSeries.this[int]' because it does not have 
        the matching return type of 'double'.
        which makes it seem impossible since I want the implementation to handle List objects.

        Maybe I'm just reading too much into the C# error message. What should I be trying to do?

        Thanks

        Comment


          #5
          Hello,

          If I'm following you correctly, you could create a list of the DataSeries objects in the following manner:

          Code:
          private List<IDataSeries> list = new List<IDataSeries>();
          
                  protected override void OnBarUpdate()
                  {
          
          			list.Add(Close);
          			list.Add(Open);
          			
          			Print("Close list: " + list[0].ToString());
          			Print("Open list: " + list[1].ToString());
          			
               
          		}
          If that does not help, can you post an example of the code you're using that generated that compile error?
          MatthewNinjaTrader Product Management

          Comment


            #6
            Hi Matthew,

            I want it the opposite way around. I want to put a List<> into each dataseries item, e.g.

            Code:
            private IDataSeries MyListDataSeries SRLevels = new MyListDataSeries();
            
            protected override void OnBarUpdate()    {     
                list = new List()<>;
                SRLevels.Add(list);

            Comment


              #7
              Hi Adamus,

              Unfortunately, you would only be able to have doubles for a data series. Anything else besides a double will cause the memory consumption to go off the scales.

              To clarify, what is the overall theme that you are trying to achieve with this code?
              Cal H.NinjaTrader Customer Service

              Comment


                #8
                Hello,

                Wanted to let you know that you can implement your own IDataSeries as it is an Interface. You would do so as follows:

                public class myCustomDataSeries : IDataSeries
                {

                }


                However this is not supported and I do not have any documentation on this, You would need to use compiler errors to inform you what members you are required to implement to satisfy the requirements of IDataSeries which there are 3 members total.

                MSDN has some information on using Interfaces that you may want to check into before diving into implementing your own class inheriting from IDataSeries.

                -Brett

                Comment


                  #9
                  Great, thanks for the info Brett. This is what I am trying to achieve, to build a class just like BoolDataSeries or DateDataSeries, except mine would be called ListDataSeries

                  I appreciate the memory consumption warning.

                  Presumably the memory consumption would be a function of the number of bars loaded on the chart, and the number of items I put in each list. Is there anything else? As the programmer, I can't and don't want to restrict the amount of days loaded, but I can put some safeguards in place to prevent huge numbers of items being put in the lists.

                  The indie is for simple support and resistance levels. I am currently keeping them all in one list sorted by price, and using a custom Plot() method to paint them.

                  However that is too simplistic because I need to remove S/R levels when they are broken so a simple price scale won't work - I also need them sorted by time as well showing when they are created and broken. Seems an ideal implementation for IDataSeries.

                  Comment


                    #10
                    Hi Adamus,

                    The supported method for accomplishing that is with a double IDataSeries object for each support/resistance level.

                    Each S/R level would be an individual DataSeries object.

                    You can then go back and and edit the values directly.

                    -Cal
                    Cal H.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks - thought about that, but part of my spec is that the S/R levels are actually zones with a ceiling and floor (and sometimes when they are close together, the indie must merge them).

                      Comment


                        #12
                        This is what I'm trying to do:

                        Code:
                                public class ListSeries : List<SRLevel>, IDataSeries
                                {
                                    public bool IsValidPlot(int x)
                                    {
                                        return true;
                                    }
                                    
                                }
                        but I can't work out how to implement the [] indexing that seems to be required - not something I've come across before - the compiler says this:

                        Indicator\PermaCodeSR005.cs 'NinjaTrader.Indicator.PermaCodeSR005.ListSeries' does not implement interface member 'NinjaTrader.Data.IDataSeries.this[int]'. 'System.Collections.Generic.List<NinjaTrader.Indic ator.PermaCodeSR005.SRLevel>.this[int]' cannot implement 'NinjaTrader.Data.IDataSeries.this[int]' because it does not have the matching return type of 'double'.

                        Can any C# coder help?

                        Thanks

                        Comment


                          #13
                          Originally posted by adamus View Post
                          This is what I'm trying to do:

                          Code:
                                  public class ListSeries : List<SRLevel>, IDataSeries
                                  {
                                      public bool IsValidPlot(int x)
                                      {
                                          return true;
                                      }
                           
                                  }
                          but I can't work out how to implement the [] indexing that seems to be required - not something I've come across before - the compiler says this:

                          Indicator\PermaCodeSR005.cs 'NinjaTrader.Indicator.PermaCodeSR005.ListSeries' does not implement interface member 'NinjaTrader.Data.IDataSeries.this[int]'. 'System.Collections.Generic.List<NinjaTrader.Indic ator.PermaCodeSR005.SRLevel>.this[int]' cannot implement 'NinjaTrader.Data.IDataSeries.this[int]' because it does not have the matching return type of 'double'.

                          Can any C# coder help?

                          Thanks
                          DataSeries is a NT construct clearly limited to hold/return a double. It can also be deduced that it is probably a Dictionary, indexed to the barSeries.

                          That is probably where you should look. Create a Dictionary that is indexed/keyed to the barSeries. You can define your Dictionary to contain anything, not just the doubles that you are restricted to with a DataSeries.

                          Comment


                            #14
                            Originally posted by koganam View Post
                            DataSeries is a NT construct clearly limited to hold/return a double. It can also be deduced that it is probably a Dictionary, indexed to the barSeries.

                            That is probably where you should look. Create a Dictionary that is indexed/keyed to the barSeries. You can define your Dictionary to contain anything, not just the doubles that you are restricted to with a DataSeries.
                            Hi Koganam,
                            thanks for the incisive explanation. I think that's a great solution since I won't have any issues with the bar updates that the DataSeries interface is designed for.

                            Correct me if I'm wrong but when you say "indexed/keyed to the barSeries" you just mean the CurrentBar int?

                            Comment


                              #15
                              Originally posted by adamus View Post
                              Hi Koganam,
                              thanks for the incisive explanation. I think that's a great solution since I won't have any issues with the bar updates that the DataSeries interface is designed for.

                              Correct me if I'm wrong but when you say "indexed/keyed to the barSeries" you just mean the CurrentBar int?
                              Pretty much.
                              Code:
                              Dictionary<TKey, TValue>()
                              TKey would be the CurrentBar each time you add to the Dictionary.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by timmbbo, Today, 08:59 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post bltdavid  
                              Started by alifarahani, Today, 09:40 AM
                              6 responses
                              40 views
                              0 likes
                              Last Post alifarahani  
                              Started by Waxavi, Today, 02:10 AM
                              1 response
                              18 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Started by Kaledus, Today, 01:29 PM
                              5 responses
                              15 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by Waxavi, Today, 02:00 AM
                              1 response
                              12 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Working...
                              X