• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.

          http://www.ninjatrader.com/support/f...d.php?p=221469

          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 rainbow47, Today, 06:10 AM
            0 responses
            3 views
            0 likes
            Last Post rainbow47  
            Started by stenberg98, Today, 04:53 AM
            2 responses
            6 views
            0 likes
            Last Post NinjaTrader_Marco  
            Started by wukefuha, Today, 03:20 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Marco  
            Started by mbcmbc, Yesterday, 10:12 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_ChrisSch  
            Started by fx.practic, Today, 03:44 AM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_Marco  
            Working...
            X