Announcement

Collapse
No announcement yet.

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.

    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.

        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?


            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.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                651 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                370 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                109 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                574 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                577 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X