Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How can I measure the slope of a line?

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

    How can I measure the slope of a line?

    Hello, how can I measure the slope of a line, in Ninja Trader?


    Thanks for the help.

    #2
    Hello ELDAVIDOLOCO,

    Thank you for your post.

    Unfortunately, there is not a drawing tool to measure the slope. You can use Slope() in NinjaScript to measure the slope of a Plot/DataSeries: http://www.ninjatrader.com/support/h.../nt7/slope.htm

    Comment


      #3
      Originally posted by ELDAVIDOLOCO View Post
      Hello, how can I measure the slope of a line, in Ninja Trader?

      Thanks for the help.
      Even though, as Patrick says, there isn't a drawing tool to measure the slope, it can be calculated using some math that you may remember from school.

      Let's say the start of the line is at Close[n] and the end at Close[0]. From geometry, we would say that X1 = n, Y1 = Close[n], X2 = 0 and Y2= Close[0].

      The formula for the slope of such a a line is:

      (X2 - X1)
      -------------
      (Y2 - Y1)

      so in NinjaScript terms this comes out as:

      Code:
      double m = - n / (Close[0] - Close[n]);
      (m being the conventional letter for 'slope'.)

      Hope this helps.

      Comment


        #4
        Looking at my last post, the formula can be simplified to avoid the 'stray' minus sign. It's easier to use:

        Code:
        double m = n / (Close[n] - Close[0]);
        (the m is of course arbitary.)

        Comment


          #5
          Originally posted by arbuthnot View Post
          Even though, as Patrick says, there isn't a drawing tool to measure the slope, it can be calculated using some math that you may remember from school.

          Let's say the start of the line is at Close[n] and the end at Close[0]. From geometry, we would say that X1 = n, Y1 = Close[n], X2 = 0 and Y2= Close[0].

          The formula for the slope of such a a line is:

          (X2 - X1)
          -------------
          (Y2 - Y1)

          so in NinjaScript terms this comes out as:

          Code:
          double m = - n / (Close[0] - Close[n]);
          (m being the conventional letter for 'slope'.)

          Hope this helps.
          Not to quibble, but actually slope is rise/run. You have that the wrong way round.

          Comment


            #6
            Thanks, Koganam!

            You are right - I am wrong!

            My math degree has been rescinded and I'm sliding down the slippery - er - slope?

            At my third attempt, this is the equation:

            Code:
            double m = (Close[n] - Close[0]) / n;
            I was in a bad mood today until I saw this: a wonderful example of my absent-mindedness!

            It's important to quibble otherwise wrong information can be left in the Forum, which helps no one.

            Much obliged to you for pointing this out.

            Cheers!

            Ed

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Barry Milan, Yesterday, 10:35 PM
            5 responses
            16 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by DanielSanMartin, Yesterday, 02:37 PM
            2 responses
            13 views
            0 likes
            Last Post DanielSanMartin  
            Started by DJ888, 04-16-2024, 06:09 PM
            4 responses
            13 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by terofs, Today, 04:18 PM
            0 responses
            12 views
            0 likes
            Last Post terofs
            by terofs
             
            Started by nandhumca, Today, 03:41 PM
            0 responses
            8 views
            0 likes
            Last Post nandhumca  
            Working...
            X