Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Last value constant

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

    Last value constant

    Learning, but I have a problem with the following:
    If I want a constant value for example the sum of the daily ATR over a 100 day period, divided by 100 for an average ATR value over that 100 day period. How can I do this or in general how can I obtain the last value of an indicator as a constant single value for all bars in the chart?

    Many thanks for helping,
    Sylvestro

    #2
    Hello,

    Thanks for the note.

    To clarify you would like to average the already averaged true range (ATR) indicator? So its double averaged? Then use that value in your calculations?

    Is the question on the averaging or on the trying to get some constant value to use that doesnt change?

    -Brett
    BrettNinjaTrader Product Management

    Comment


      #3
      constant value

      The question is to get some constant value as a result of a calculated indicator. What is the median value of an indicator over a period of time.
      Sylvestro

      Comment


        #4
        Indicators are calculated with each new bar. If you want the latest value of an indicator, you can check its value by looking at the most recently updated value.

        If you want your lookbacks to calculate all bars in the chart, can use CurrentBar + 1.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Sylvestro,

          I am happy to assist.

          Do you want the median or the average (mean)? They are two different things.

          I believe you could use a SMA with a period of 100 to get an mean over 100 bars.

          For example with the ATR, I could use : SMA(ATR(ATRperiod),100); to get the average value over 100 bars.

          If you want a median its a bit different because you will have to sort the dataseries.
          Last edited by NinjaTrader_AdamP; 11-16-2011, 12:15 PM.
          Adam P.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_AdamP View Post
            ... If you want a median its a bit different because you will have to sort the dataseries.
            Not quite. NT has a GetMedian() function built in. And, the median is just another measure of the average, especially useful for data that is either fat-tailed (a few large outliers, especially if at only one end), or just not Gaussian distributed. Sure the mean (which many people think is the only measure of the average), can be, and is often, a different value from the median, but the median is an average.

            Comment


              #7
              koganam,

              Thanks for the clarification as to a statistical average being any one in the set of median, mean, etc.

              GetMedian() does indeed sort the data series and then picks the middle value, or the mean of the middle two values. I am not sure what sorting algorithm it uses so it could either be O(n log n) or O(n^2) time complexity and will slow down calculations with large look back period. Short of estimating the median using some mathematical technique, or using an algorithm like this : http://en.wikipedia.org/wiki/Selecti...ians_algorithm ; sorting, then picking the "middle value" is the only way to get it and tends to be the easiest way of implementing this. In the help guide it mentions GetMedian() sorts.

              Please let me know if I may assist further,
              Adam P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              607 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              353 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              105 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              560 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              561 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X