Announcement

Collapse
No announcement yet.

how does esignal calulate atr?

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

  • how does esignal calulate atr?

    i assume this a relatively simple question, what i would like to know is how esignal calculates atr, because ((high(0) - low(0))+(high(-1)-low(-1)))/2 doesnt seem to give me the same result as atr(2). so i assume the calculation isnt just the high minus the low, unless im doing something wrong.

    thanks

  • #2
    Re: how does esignal calulate atr?

    kalzenith
    See this article in the Technical Analysis Dictionary folder of the eSignal KnowledgeBase which describes how the True Range is calculated
    Alex


    Originally posted by kalzenith
    i assume this a relatively simple question, what i would like to know is how esignal calculates atr, because ((high(0) - low(0))+(high(-1)-low(-1)))/2 doesnt seem to give me the same result as atr(2). so i assume the calculation isnt just the high minus the low, unless im doing something wrong.

    thanks

    Comment


    • #3
      i already have, but this doesnt seem to return the same result..

      PHP Code:
      var one 0;
      var 
      two 0;
      var 
      three 0;
      var 
      four 0;
      var 
      five 0;
      var 
      0;
      var 
      R1 0;

      function 
      main() {

      one high()-low()
      two high() - close(-1)
      three close(-1) - high()
      four low() - close(-1)
      five close(-1) - low()

      R1 R

      one
      if (two Rtwo
      if (three Rthree
      if (four Rfour
      if (five Rfive

      return new Array (
          
      atr(2),
          (
      R1)/2
      )

      Last edited by kalzenith; 10-19-2008, 08:33 AM.

      Comment


      • #4
        i edited the code below, i found some pretty obvious errors in the logic, but im still not getting the same value the atr() function gives

        Comment


        • #5
          kalzenith
          You can find an example of the required logic in the ATR.efs which is installed in the Library folder of Formulas
          Alex


          Originally posted by kalzenith
          i edited the code below, i found some pretty obvious errors in the logic, but im still not getting the same value the atr() function gives

          Comment


          • #6
            that efs help a bit, i made a function to call that will return an atr of length 1 and it looks like it is 100% accurate, but i tried inserting the function into an sma() using efsInternal, and it doesnt seemt o have worked, does anyone know why this might be?

            PHP Code:
            function main() {
            return new Array (
                
            atr(30),
                
            sma(30,efsInternal("calc"))
            )
            }
            function 
            calc() {
            return 
            Math.max(high()-low(), Math.abs(high() - close(-1)), Math.abs(low() - close(-1)))

            Comment


            • #7
              kalzenith
              The ATR study does not use a simple moving average for its calculations but the following smoothing method
              (previous_ATR*(period-1)+current_true_range)/period
              You can find the complete logic in the efs I mentioned
              Alex


              Originally posted by kalzenith
              that efs help a bit, i made a function to call that will return an atr of length 1 and it looks like it is 100% accurate, but i tried inserting the function into an sma() using efsInternal, and it doesnt seemt o have worked, does anyone know why this might be?

              PHP Code:
              function main() {
              return new Array (
                  
              atr(30),
                  
              sma(30,efsInternal("calc"))
              )
              }
              function 
              calc() {
              return 
              Math.max(high()-low(), Math.abs(high() - close(-1)), Math.abs(low() - close(-1)))

              Comment

              Working...
              X