Announcement

Collapse
No announcement yet.

The angle of a Moving Average

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

  • The angle of a Moving Average

    Is there an EFS file to calculate the angle of a Moving Average, if not then how would you write an EFS file to calculate the angle of a moving average, whether it’s 45deg, 60deg, etc….

    Thank you

    Ketoma

  • #2
    Hello Ketoma,

    Here is a code example for working with angles. This information is from the EFS Help Center & Library.

    Misc. Formulas

    Calculate the angle (in degrees) of a slope:

    //Assume a 30% slope (rise over run);
    nSlope = 0.30;
    nAngle = Math.atan( nSlope ) / ( Math.PI/180 );
    nAngle now equals approx 16.67 Degrees.



    Calculate the slope (in %) from an angle:

    //Assume a 20-degree angle
    nAngle = 20.0;
    nSlope = Math.tan( nAngle * (Math.PI/180) );
    nSlope now equals 0.3639 or a 36.39% slope.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Hello Jason

      Thank you very much for the quick reply.

      I saw this formula along time ago. The thing that I don’t understand how do you assume a 30% slope. How do you find the slope?

      Assume a 30% slope (rise over run);

      Thank you

      Comment


      • #4
        Hello Ketoma,

        Slope is simply rise over run or,

        (yValue0 - yValue1) / (xValue0 - xValue1)

        where the yValues are the values of your indicator on the y-axis and the xValues are x-axis values. You could use the bar index numbers for the xValues. Take the absolute value of the difference of the index values between the two bars in question.
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          Hi,
          Here's a study i downloaded from the BB a few months ago.

          Paul
          Attached Files

          Comment


          • #6
            I wonder if there is a script displaying a line connecting last point of MA to its point n bars ago, where "n" is an editable constant.

            Comment


            • #7
              greg108
              The attached efs draws a line from the current MA value to the MA's value "n" bars back (default is 0). In the image below for example the "n" lookback is set to 35 (which you can see in the Csr# in the Cursor Window)



              All parameters of the MA and the "n" lookback period can be modified via Edit Studies. The "n" lookback value is a positive number even if it relates to negative bar index
              Alex
              Attached Files

              Comment

              Working...
              X