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

Average True Range (ATR) calculation

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

    Average True Range (ATR) calculation

    Hello. I didn't pay attention to ATR indicator results, before saw other result for the same instrument and period. Can anybody explain why ATR with 14 periods back shows 26.72 in ES 12-15 EOD 30.10.2015?! I even calculate the same in Excel and get 21.92.

    #2
    Hello alexstox,

    Thanks for your post.

    I applied the ATR indicator, set to a period of 14, set to CalculateOnBarClose = false, using Kinetic End of day data, on ES 12-15. The ATR value on 10-30-2015 is as you show 26.72.

    Can you clarify how you calculated the ATR at 21.92?
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Here is Excel file calculation
      ATR ES 12-15 Last.zip

      Comment


        #4
        Hello alexstox,

        Thanks for your reply.

        I have been able to confirm that your true range values match what is produced in Ninjatrader. However to complete the calculations for the ATR you would need to:

        ((period -1) * Value[1] + true range) / period

        Where period in this case is 14 and Value[1] is the prior ATR value and true range is this periods true range.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by alexstox View Post
          Here is Excel file calculation
          [ATTACH]35544[/ATTACH]
          Your Excel file is calculating based on an SMA: NT calculates based on an EMA. (More specifically, the Wilder's Moving Average).
          Last edited by koganam; 11-02-2015, 01:48 PM.

          Comment


            #6
            Originally posted by NinjaTrader_Paul View Post
            Hello alexstox,

            Thanks for your reply.

            I have been able to confirm that your true range values match what is produced in Ninjatrader. However to complete the calculations for the ATR you would need to:

            ((period -1) * Value[1] + true range) / period

            Where period in this case is 14 and Value[1] is the prior ATR value and true range is this periods true range.
            Still can't get NT value =)))
            ATR ES 12-15 Last.zip

            Comment


              #7
              Hello alexstox,

              Thanks for your reply.

              The forumla in the spreadsheet is not correct and it is important to make sure that you start with the previous ATR value (which is based on the previous 14 ATRs).

              Starting with row 3, the true range value is 19.25 and the previous ATR value needs to be 34.94518. Period is 14 so the formula, for row 3, needs to be:

              ATR = (Period -1 * previous ATR + true range) / Period

              ATR = (13 * 34.94518 + 19.25) / 14

              ATR for row 3 = 33.8241

              When you extend that to the last row of your spreadsheet, the ATR value is 26.72354 which matches the ATR on the chart.
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Let us look a bit at the history of technical analysis.

                The average true range was created by Welles Wilder. I have read his wonderful book "New Concepts in Technical Trading Systems" from 1978. At that time there were no PCs available. The book shows manually drawn charts on graph paper. All the indicator values had to be calculated by hand every day.

                If you have to calculate indicator values by hand, you will soon find out that an EMA is much easier to calculate compared to a SMA. You just need to enter two values, yesterday's indicator value and today's price and then calculate the new indicator value.

                NinjaTrader's implementation of the ATR follows Wilder's concept. This means that the ATR is calculated as Wilder's average of the true range - and not as a regular EMA of the true range. The EMA formula which is in use today was only suggested by Jack K. Hutson in 1984 (cmp. March 1984 issue of "Stocks & Commodities"). The main difference is the relationship between the indicator period N and the smoothing constant. If you select a period N, Wilder uses a smoothing constant of 1/N, while Hutson (and all modern charting programs) use a smoothing constant of 2/(N+1) for calculating the EMA.

                For example if you select a period K for the average true range, you will find

                ATR(K) = EMA(TR, 2*K-1)

                This can be easily shown with a NinjaTrader chart, see chart attached. The True Range itself is not available as a NinjaTrader indicator, but you can substitute TR = ATR(1).

                Now there are many charting packages that do not follow the original idea of Wilder Welles, but they suggest to use a formula where

                Average True Range = SMA(TR, 2*K-1)

                Of course this is possible, as you can use different averages for smoothing the true range. Both concepts have an advantage and an inconvenient.

                Simple smoothing: If the lookback period is 14, you only need 14 bars to calculate the exact value. Large bars dropping out of the calculation at the other end have a significant impact on the indicator value.

                Exponential smoothing: The exponentially smoothed ATR is a IIR filter which means that the current value is influenced by all prior values of the True Range. In practice this will require 3 times as many bars for an accurate calculation, before you get the exact value.

                Again, NinjaTrader uses exponential smoothing in line with the original concept developed by Welles Wilder, and AFAIK everything is correct.
                Attached Files

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by wzgy0920, 04-20-2024, 06:09 PM
                2 responses
                27 views
                0 likes
                Last Post wzgy0920  
                Started by wzgy0920, 02-22-2024, 01:11 AM
                5 responses
                32 views
                0 likes
                Last Post wzgy0920  
                Started by wzgy0920, 04-23-2024, 09:53 PM
                2 responses
                49 views
                0 likes
                Last Post wzgy0920  
                Started by Kensonprib, 04-28-2021, 10:11 AM
                5 responses
                193 views
                0 likes
                Last Post Hasadafa  
                Started by GussJ, 03-04-2020, 03:11 PM
                11 responses
                3,235 views
                0 likes
                Last Post xiinteractive  
                Working...
                X