Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Slope method return clarification

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

    Slope method return clarification

    Hello

    I am trying to use the slope of a moving average in my indicator, but it is not clear to me what the slope method actually returns.

    When I print the result of " Math.Atan(Slope(T31, 10, 0)) * 180 / Math.PI ", it shows about 3.4466, which according to the formula it should be decimal degrees, but on the chart it looks like over the last 10 bars, the slope is steeper than 45 deg, so my question is: what is 3.4466, as it can't possibly be decimal degrees?

    What I am trying to achieve is determining when the moving average has been rising for a certain number or periods.

    Thank you
    Last edited by itrader46; 03-03-2020, 01:09 PM.

    #2
    Hello itrader46,


    45 degrees would be a vertical line.. If its greater than 45 then its sloping in the other direction and the Slope() method will provide a negative value
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea.

      I'm sorry, but you lost me here: 45 degrees would be a vertical line? How is that?

      And, in my case, what is 3.4466 related to a line rising at an angle of about 60 degrees from the horizontal?

      Comment


        #4
        Hello itrader46,

        Apologies, you are correct, a 45 degree angle would be a true diagonal.. 90 degrees would be a vertical line..

        I recommend you print the bar values so that we can see if this makes sense.

        Try the following print:
        Code:
        Print(string.Format("{0} | T31[0]: {1} - T31[10]: {2} / 10 = {3}, Slope: {4}, Degrees: {5}", Time[0], T31[0], T31[10], ((T31[0] - T31[10]) / 10), Slope(T31, 10, 0), (Math.Atan(Slope(T31, 10, 0)) * 180 / Math.PI)));
        What is the output from this on the bar in question?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea

          I modified the print slightly as below to make it easier readable and this is the result:

          Bar [0]: 6132 | T31[0]: 47.37 - T31[10]: 47.75 / 10 = -0.04, Slope: -0.04, Degrees: -2.13, Bar [10]: 6122
          -
          Bar [0]: 6133 | T31[0]: 47.35 - T31[10]: 47.75 / 10 = -0.04, Slope: -0.04, Degrees: -2.30, Bar [10]: 6123
          -
          Bar [0]: 6134 | T31[0]: 47.32 - T31[10]: 47.74 / 10 = -0.04, Slope: -0.04, Degrees: -2.39, Bar [10]: 6124
          -
          Bar [0]: 6135 | T31[0]: 47.30 - T31[10]: 47.71 / 10 = -0.04, Slope: -0.04, Degrees: -2.36, Bar [10]: 6125
          -

          I suppose the degrees values would be right after all, given the fact that the length is 10 and the height is -0.41, as in the case of the last print, but it looks nothing like on the chart.

          Since that is of not much use if I wanted to find T31 falling over the last 10 bars, do you have any advice on how to achieve that?

          Code:
          Print(string.Format("Bar [0]: {0} | T31[0]: {1:F2} - T31[10]: {2:F2} / 10 = {3:F2}, Slope: {4:F2}, Degrees: {5:F2}, Bar [10]: {6}", CurrentBar, T31[0], T31[10], ((T31[0] - T31[10]) / 10), Slope(T31, 10, 0), (Math.Atan(Slope(T31, 10, 0)) * 180 / Math.PI), (CurrentBar - 10)) + "\r\n-");
          Last edited by itrader46; 03-04-2020, 05:36 AM.

          Comment


            #6
            Hello itrader46,

            Thanks for your reply.

            Regarding, "I wanted to find T31 falling over the last 10 bars, do you have any advice on how to achieve that?"

            A positive slope value would indicate rising, a negative slope value would indicate falling.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            648 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 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
            573 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            575 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X