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 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.

    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.

        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.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rhyminkevin, Today, 04:58 PM
            2 responses
            45 views
            0 likes
            Last Post loosek
            by loosek
             
            Started by iceman2018, Today, 05:07 PM
            0 responses
            5 views
            0 likes
            Last Post iceman2018  
            Started by lightsun47, Today, 03:51 PM
            0 responses
            7 views
            0 likes
            Last Post lightsun47  
            Started by 00nevest, Today, 02:27 PM
            1 response
            14 views
            0 likes
            Last Post 00nevest  
            Started by futtrader, 04-21-2024, 01:50 AM
            4 responses
            49 views
            0 likes
            Last Post futtrader  
            Working...
            X