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

ATR as percent

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

    ATR as percent

    I have copied over the ATR indicator and modified it with the following to get the ATR as a percent value:

    double close1 = Close[1];
    double trueRange = Math.Max(Math.Abs(low0 - close1), Math.Max(high0 - low0, Math.Abs(high0 - close1)));
    Value[0] = ((((Math.Min(CurrentBar + 1, Period) - 1 ) * Value[1] + trueRange) / Math.Min(CurrentBar + 1, Period))/Close[1])*100;



    This does not give the correct value of the ATR. - any thoughts on this?

    Regards

    Francis ​

    #2
    Hello elliot5,
    Are you seeing the actual ATR value is incorrect or it is incorrect after your addition of new math?

    I see that you copied the logic here, you can also call the ATR indicator directly to get its value.

    JesseNinjaTrader Customer Service

    Comment


      #3
      The ATR value is correct but the addition of new math gives wrong value. Regards

      Comment


        #4
        Hello elliot5,

        As the ATR is not a price value using the price as part of the percent calculation would cause odd results. Are you trying to something similar to the answer in the following forum post?



        You would otherwise need to find the maximum value of the ATR within the period you wanted and then use that as the number for the percentage math. The atr value could be a percentage of that maximum atr value.
        JesseNinjaTrader Customer Service

        Comment


          #5
          No I just want the DailyATR expressed as a percentage of the series value that if is calculated on. Regards

          Comment


            #6
            Hello elliot5,

            We may end up making more guesses here, but if I were to translate the phrase:

            "Percentage of the daily ATR, as it is taken from the entire range of the past X days"

            That would mean the "entire range of the past X days" would involve getting Highest High, and Lowest Low over the past X days for the denominator, and then use the daily atr as the numerator.

            So that phrase may look like:

            DailyATR[0] / (MAX(High, 5)[0] - MIN(Low, 5)[0])

            If this does not better answer the question, can you be more specific, or rephrase illustrate what you are looking for as the denominator?


            JimNinjaTrader Customer Service

            Comment


              #7
              If the s&P is at 3600 and the ATR Daily bars is 80 then the % ATR of index = 2.22 %. I want the ATR expressed as a percentage of the index - so added the simple math onto the daily ATR indicator - which gives a false value for that percentage. Regards

              Comment


                #8
                Hello elliot5,

                For what you described that would require using a simple percentage math which involves both division and multiplication. 80 divided by 3600 is 0.02. 0.02 times 100 gives you 2.22.

                If you are having trouble seeing an incorrect value you will need to use Prints in the scripts code so you can see what the actual values of each part of your math are to get a better idea of what's going wrong.
                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by kevinenergy, 02-17-2023, 12:42 PM
                117 responses
                2,766 views
                1 like
                Last Post jculp
                by jculp
                 
                Started by Mongo, Today, 11:05 AM
                5 responses
                15 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by SightCareAubetter, Today, 12:55 PM
                0 responses
                3 views
                0 likes
                Last Post SightCareAubetter  
                Started by traderqz, Today, 12:06 AM
                8 responses
                16 views
                0 likes
                Last Post traderqz  
                Started by SightCareAubetter, Today, 12:50 PM
                0 responses
                2 views
                0 likes
                Last Post SightCareAubetter  
                Working...
                X