Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IDataSeries with User Defined Methods

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

    IDataSeries with User Defined Methods

    Hi,

    I feel like I have seen an answer to this question in the forum but for the life of me, I can't find it.

    I have some code I use over and over and currently have it in an indicator. Now I need to make changes that I would prefer to have as a User Defined Method.

    If I pass in a secondary BarsArray i.e. BarsArray[1] and in the method accept an IDataSeries parameter i.e. public void SomeMethod(IDataSeries dsBase, int length)

    how do I reference the individual components of the BarsArray Open, High, Low, Close, Time?

    I want the values associated with the BarsArray i.e. if it were a 5 minute bar for Time, I would get 1205 whereas if I then called the same method with a 60 minute bar, I would get 1200 because that would be the last full bar.

    I would ideally like the equivalent of dsBase.High[1] and dsBase.Time[3]

    Thanks in advance.

    Scott

    #2
    Hello,

    You can pass data series but it only passes one of those at a time.

    This should clear it up for you: http://www.ninjatrader.com/support/h...dataseries.htm

    So if you needed, High, low, open, close. You would need to have a method with 4 parameters and 4 data series passed into it.
    BrettNinjaTrader Product Management

    Comment


      #3
      Brett, that is the conclusion I had come to but hoped to get a way around that. So I need to pass in 5 DataSeries, OHLC + Time?

      Out of curiosity, why can you pass in a BarsArray if it only uses one of the values it provides (presumably Close)?

      Best Regards,
      Scott

      Comment


        #4
        You would access BarsArray though:

        Highs[1];
        //Outputs a iDataSeries for thte Highs in BarsArray1

        You include an s to indicate your accessing another BarsArray then the primary.

        If you want to output the high price of the secondary BarsArray from the current bat:

        Highs[1][0];
        //Outputs a double for that bar index and bars back.



        Using Bars Objects as Input to Indicator Methods

        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment


          #5
          Brett, thanks for the reply. I understand it on the passing side, I was referring to the UserDefinedMethods side. MyMethod(IDataSeries ds1...

          Comment


            #6
            Hello,

            Yes if you pass it simply defaults in a iDataSeries which would then be the first data series in the BarsArray which is simply Close.
            BrettNinjaTrader Product Management

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            581 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            338 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X