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

Calculating Median and (n)th Percentile

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

    Calculating Median and (n)th Percentile

    Can I ask which function calculates median of given series and also how can we calculate for example 70th percentile of given series?

    PS: I'm not talking about Median of a bar...

    Thanks
    Last edited by Atilla; 04-07-2019, 09:48 AM.

    #2
    Originally posted by Atilla View Post
    Can I ask which function calculates median of given series and also how can we calculate for example 70th percentile of given series?

    PS: I'm not talking about Median of a bar...

    Thanks
    NT has a method called GetMedian(), to calculate the median, and has now precisely explained their misuse of the term when referenced to bar range.

    ref: https://ninjatrader.com/support/help.../getmedian.htm

    To calculate percentiles, you would have to write the method yourself. It consists essentially of sorting a list of values and determining what is at the index that represents the required percentile value of the size of the list.

    Comment


      #3
      Originally posted by koganam View Post
      NT has a method called GetMedian(), to calculate the median, and has now precisely explained their misuse of the term when referenced to bar range.

      ref: https://ninjatrader.com/support/help.../getmedian.htm

      To calculate percentiles, you would have to write the method yourself. It consists essentially of sorting a list of values and determining what is at the index that represents the required percentile value of the size of the list.
      Thanks a lot. I can use SMA() following way
      SMA(Open, Lookback)[i];

      However, i can not use GetMedian() same way:
      GetMedian(Open, Lookback)[i];

      Do you know how to fix it?

      Comment


        #4
        Originally posted by Atilla View Post

        Thanks a lot. I can use SMA() following way
        SMA(Open, Lookback)[i];

        However, i can not use GetMedian() same way:
        GetMedian(Open, Lookback)[i];

        Do you know how to fix it?
        There is an example right on the page that I referenced. Am I missing something?

        If you mean that you want to specify a specific bar (back or by index) from which to calculate the starting value of the median that you seek, that is not a method that ships in the product. You will have to write a method to do it. You already know that the median is the 50th percentile.
        Last edited by koganam; 04-08-2019, 08:16 AM.

        Comment


          #5
          Hello Atilla,

          GetMedian() returns a double. This method does not return a series. An index cannot be used as this is not a series, collection, or array. (Calling SMA() returns a plot series)


          Use this the way a double would be used.
          double myDouble = GetMedian(Open, Lookback);
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by koganam View Post

            There is an example right on the page that I referenced. Am I missing something?

            If you mean that you want to specify a specific bar (back or by index) from which to calculate the starting value of the median that you seek, that is not a method that ships in the product. You will have to write a method to do it. You already know that the median is the 50th percentile.
            yep i know that but i'm Python guy

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello Atilla,

              GetMedian() returns a double. This method does not return a series. An index cannot be used as this is not a series, collection, or array. (Calling SMA() returns a plot series)


              Use this the way a double would be used.
              double myDouble = GetMedian(Open, Lookback);
              is there a way i can set it to Series?

              Comment


                #8
                Hello Atilla,

                To confirm you are wanting the value of the median of the bars in the Lookback range calculated and then saved to a series for every bar?

                You can create a custom series and save the median value to the custom series.

                Below is a link to the help guide.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by chbruno, Today, 04:10 PM
                0 responses
                3 views
                0 likes
                Last Post chbruno
                by chbruno
                 
                Started by josh18955, 03-25-2023, 11:16 AM
                6 responses
                436 views
                0 likes
                Last Post Delerium  
                Started by FAQtrader, Today, 03:35 PM
                0 responses
                6 views
                0 likes
                Last Post FAQtrader  
                Started by rocketman7, Today, 09:41 AM
                5 responses
                19 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by frslvr, 04-11-2024, 07:26 AM
                9 responses
                127 views
                1 like
                Last Post caryc123  
                Working...
                X