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

Median of DataSeries

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

    Median of DataSeries

    Howdy--

    Is there a quick and easy way to calculate a median of the values in a DataSeries?

    Thanks,

    Aventeren

    #2
    Originally posted by aventeren View Post
    Howdy--

    Is there a quick and easy way to calculate a median of the values in a DataSeries?

    Thanks,

    Aventeren
    GetMedian()? Read the manual.

    ref: http://www.ninjatrader.com/support/h.../getmedian.htm

    Comment


      #3
      Pay attention though, GetMedian(N) returns the median of the last N+1 values.

      For example, GetMedian(5) returns the median of the last 6 values of a DataSeries.

      Comment


        #4
        Thanks, guys. I figured that there must have been a canned Median method, but when I searched for Median I only found the canned Median[barsAgo] function, which wasn't what I was looking for.

        Thanks, Harry for the note on N vs N + 1. I'll need to see how it works, as in my mind a Median method should just take a List or DataSeries in, then determine the number of elements, and then either take the middle of an odd count of the average of the 2 middle elements in an even count. Do you have any backstory on why GetMedian(5) would return the median for the last 6 values of the DataSeries?

        All best,

        Aventeren

        Comment


          #5
          Originally posted by Harry View Post
          Pay attention though, GetMedian(N) returns the median of the last N+1 values.

          For example, GetMedian(5) returns the median of the last 6 values of a DataSeries.
          Yes. As explained in this thread that you opened on the issue.



          I still must say though that the promised change in the documentation to reflect this is done in a rather obscure fashion. Instead of noting it in the description of the method, it is only noted, pretty much "in passing", in the given example. Many, who are not as anal-retentive as some of us when we read, will probably miss the caveat.
          Last edited by koganam; 10-07-2014, 09:24 AM.

          Comment


            #6
            Right on, thanks. I'll just write my own Median method and post it here for others to copy and paste in. I'll just create a method to take in a DataSeries, and then I'll use IsOdd to determine if I should be taking the middle element or the average of the two middle elements (i.e., if !IsOdd()).

            Thanks for your help, guys.

            All best,

            Aventeren

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Segwin, 05-07-2018, 02:15 PM
            14 responses
            1,788 views
            0 likes
            Last Post aligator  
            Started by Jimmyk, 01-26-2018, 05:19 AM
            6 responses
            837 views
            0 likes
            Last Post emuns
            by emuns
             
            Started by jxs_xrj, 01-12-2020, 09:49 AM
            6 responses
            3,293 views
            1 like
            Last Post jgualdronc  
            Started by Touch-Ups, Today, 10:36 AM
            0 responses
            13 views
            0 likes
            Last Post Touch-Ups  
            Started by geddyisodin, 04-25-2024, 05:20 AM
            11 responses
            63 views
            0 likes
            Last Post halgo_boulder  
            Working...
            X