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

IDataSeries - Can we implement and pass to NT methods/functions?

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

    IDataSeries - Can we implement and pass to NT methods/functions?

    I’m porting some indicators from TS to NT. One of them uses the TS function:
    LinearRegValue. What’s nice about this function is that the data series that’s passed for it to operate on can be something that my indicator calculates ( it can be an expression ).

    I see that NT abstracts the concept of a data series in IDataSeries. To achieve the goal of calculating my own data series for a linear regression, I implemented IDataSeries in my own class, which is nested in my main Indicator derived class:

    public class MySeries : IDataSeries {…}

    Then I moved the calculations for the LinReg series argument into that IDataSeries implementation.

    Next the NT indicator is calling

    LinReg( new MySeries(),20 );

    No compliation errors.
    To my surprise, at runtime, NT throws an exception with a message that says the dataseries type is unexpected:
    'OnBarUpdate' method for indicator 'TestIndicator' on bar 0: IndicatorBase.set_Input: Unexpected 'DataSeries' type: NinjaTrader.Indicator.ATMSqueeze+MySeries

    Questions:
    1) Is NT deliberately doing a runtime check on data types and throwing exceptions if the types are not in a list of “sanctioned” types of NT origin? If so then the abstraction of IDataSeries is a bit misleading to the development community.
    2) How can I get LinReg to operate on a data series that I calculate myself?

    #2
    Brillo,

    Unfortunately we do not support deriving your own class from IDataSeries. You will have to use DataSeries.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Josh View Post
      Brillo,

      Unfortunately we do not support deriving your own class from IDataSeries. You will have to use DataSeries.
      Hi Josh,
      Thank you for replying promptly. I would appreciate further explanation. I'm new to NT. The reason I'm looking into NT is because of it's C# programming interface. I ran directly into this problem on my 1st indicator authoring attempt.

      1) Is there a work around to get LinReg to operate on a series of data that my indicator calculates?
      2) What's the rationale behind preventing us from supplying our own IDataSeries implementation? Does it pose a threat to NT or it's partners? I assume there's some threat because: A) Preventing it creates a lack of functionality and breaks the beauty of the object oriented model and it's inherent benefits. B) Preventing it had to be explicitly coded. It's not an oversight.

      Comment


        #4
        1. You can create your own DataSeries. I am not sure what more you would need. If you don't want to use DataSeries, then you can just roll your own methods completely.

        2. Unfortunately it is what it is.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Hi Josh,
          This DataSeries class looks like it will do what I need. I didn't understand the 1st time you mentioned it. I didn't know it was actually a class. I thought you where referring to native NT types such as close, open, high, etc. collectively as "DataSeries" and that you were saying that I have to use only those! I told you I was new.

          Comment


            #6
            I also want to pass indicators to custom data-series created during my strategies.

            In general the data-series has to be linked to an indicator or a bar. This allows NT to create as many dataseries elements as there are bars in the chart, which permits simple indexing.

            However there are situations where the series you want to call the indicator on does not have a one-to-one correspondence with any bar in the indicator/strategy. I want to implement the IDataSeries interface in something which is like a data-series but where the number of bars is not tied to any particular bar series in the strategy.

            This need arises because I want some indicators on RTH trading data and some indicators to run on 24/7 data. Currently, I do not think you can specify the session you want to link to when you add a new bar object to a strategy. So I am being forced to create my own custom data-series with RTH only data from the strategy running 24/7. However linking this series to the 24/7 main series running in the strategy defeats the purpose of having bars representing RTH data only.

            I can workaround the inability to chose the session I want to tie a new bar object to by maintaining my own DataSeries which is not tied to any bar in the current strategy. Is it possible somehow in NT7?

            Comment


              #7
              Hello,

              I'll have Josh reply on Monday.
              DenNinjaTrader Customer Service

              Comment


                #8
                aviat72,

                If you do not want it tied to bars you will need to use C# arrays instead. Unfortunately I have no resources I can offer you in terms of using arrays, but there are a lot of good resources you can find on google on how to use arrays. You want to use those objects instead of DataSeries objects and your parameter should be looking for arrays instead as well.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Josh View Post
                  aviat72,

                  If you do not want it tied to bars you will need to use C# arrays instead. Unfortunately I have no resources I can offer you in terms of using arrays, but there are a lot of good resources you can find on google on how to use arrays. You want to use those objects instead of DataSeries objects and your parameter should be looking for arrays instead as well.
                  Josh

                  I was hoping not to have to rewrite the indicators to accept arrays.

                  In my situation I want a bar series from a different session in the same strategy. I can manually create the bar-series by filtering the incoming bars but do not have a class which implements the IDataSeries interface to pass it to the indicators.

                  Comment


                    #10
                    Unfortunately IDataSeries objects would have to be tied to a bar series and that would mean the same number of indexes as the underlying bar series. If you want to just "ignore" some bars you can try not setting any values on the bars you don't want.
                    Josh P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by GussJ, 03-04-2020, 03:11 PM
                    16 responses
                    3,279 views
                    0 likes
                    Last Post Leafcutter  
                    Started by WHICKED, Today, 12:45 PM
                    2 responses
                    19 views
                    0 likes
                    Last Post WHICKED
                    by WHICKED
                     
                    Started by Tim-c, Today, 02:10 PM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by Taddypole, Today, 02:47 PM
                    0 responses
                    5 views
                    0 likes
                    Last Post Taddypole  
                    Started by chbruno, 04-24-2024, 04:10 PM
                    4 responses
                    52 views
                    0 likes
                    Last Post chbruno
                    by chbruno
                     
                    Working...
                    X