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 cre8able, Today, 01:16 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by chbruno, 04-24-2024, 04:10 PM
            3 responses
            47 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by samish18, Today, 01:01 PM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by WHICKED, Today, 12:56 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by WHICKED, Today, 12:45 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X