Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Formula of Slope

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

    Formula of Slope

    Hi,

    I'm a NT newbie and trying to create a simple formula for calculating the slope value of the Highest Highs.

    What I can't figure, however, is how I can extract the number of bar. With the HighestBar() method I can get the number of bars within the lookback period, but how can I get the number of bars ago for the period preceding the current one?

    Below is the formula (currently not working) for what I am trying to do:

    Slope1= Slope((MAX(High,ratio)[0]-MAX(High,ratio)[ratio]),1,0);

    here's I am calculating the Highest High for the current period (say, 5 bars - from 0 to 4th) and the HH for the period from 5th to 9th.

    Generally speaking, what is there universal method for getting time stamp or # of bars ago for given event?

    Thanks!

    #2
    msamadov,

    You need to store your calculations into a DataSeries before you can run Slope() on it. Please see this article: http://www.ninjatrader-support.com/H...taSeriesObject

    To get the timestamp of your bars just use Time[0] where 0 is the index of the bar you want the timestamp of.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      How to Find the Slope of a LineBack to Top
      Determine the slope of a line, which contains the points A (-1, -2), B (-2, 1):

      Solution:

      Here, x1 = -1, x2 = -2, y1 = -2, y2 = 1.

      Slope of the line, m = [ (y2 - y1)/(x2 - x1)]

      = [(1 + 2)/(-2 + 1)]

      = [3/(-1)]

      Slope of the line (m) = -3


      The slope formula of the line is:

      Slope (m) = [ (y2 - y1)/(x2 - x1)]



      Slope (m) =Rise / Run

      (Rise = change in the y co-ordinate; Run = change in the x co-ordinate)

      In the above given graph, the Rise is given for the points B (4,2) and C (4,4) and the Run is given for the points A (2,2) and B (4,2)

      Rise = change in the y - coordinate = 4-2 =2

      Run = change in the x- coordinate = 4-2 =2

      Using the slope formula, we get :

      Slope( m ) = Rise / Run = 2 / 2 =1

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by inanazsocial, Today, 01:15 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by rocketman7, Today, 02:12 AM
      0 responses
      6 views
      0 likes
      Last Post rocketman7  
      Started by dustydbayer, Today, 01:59 AM
      0 responses
      1 view
      0 likes
      Last Post dustydbayer  
      Started by trilliantrader, 04-18-2024, 08:16 AM
      5 responses
      23 views
      0 likes
      Last Post trilliantrader  
      Started by Davidtowleii, Today, 12:15 AM
      0 responses
      3 views
      0 likes
      Last Post Davidtowleii  
      Working...
      X