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

Slope() Range

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

    Slope() Range

    What is the valid range of the Slope function? The help is a little weak on this. Is the 3p position=0 degrees, 12 noon=90 degrees, and 6p=-90 degrees?

    Thanks!

    #2
    There is no valid range of slope nor can you equate slope to the angle of incline or decline.

    Slope is only the measure of how much a line increases or decreases in slope over the given range.

    Slope(SMA(20), CurrentBar - 10, CurrentBar)

    returns the slope of a 20 period SMA over 10 bars. Assuming the slope was positive, it would simply mean that the value of the line increased X over the last 10 bars.
    RayNinjaTrader Customer Service

    Comment


      #3
      Follow Up Question

      What is 'X' then? Pixels; twips; dollar amount?

      Comment


        #4
        If you pass in a price series into the Slope() method, it would represent price, if you pass in an indicator such as CCI it would represent the CCI plot value etc..
        RayNinjaTrader Customer Service

        Comment


          #5
          moflaherty,

          You may want to check out this thread :

          Comment


            #6
            Angle Method?

            Thank you for your replies.

            I have read that thread, but need to read it some more. It is deep.

            I am not a chart technician; I only play one in the futures market. I am a shrink-wrap programmer by trade. My first impulse in trying to write indicators was to convert everything into angles, degrees, and triangles. I was drawn to Slope() because it sounded like what I was looking for.

            I am not sure if true chart technicians would agree, but I would think a method like this would be useful:

            Syntax
            Angle(IDataSeries series, int startBar, int endBar)
            This method returns a double value indicating the degree of a line.

            It would use a routine like this one to return the angle: http://64.233.167.104/search?q=cache:Ra_R2faqt5IJ:www.uk-dave.com/bytes/java/angle-points.php+calculating+angle+of+two+points&hl=en&c t=clnk&cd=2&gl=us

            You could use the center of a bar to anchor the horizontal coordinate.

            Just a thought!

            Michael

            Comment


              #7
              Originally posted by moflaherty View Post
              Syntax
              Angle(IDataSeries series, int startBar, int endBar)
              This method returns a double value indicating the degree of a line.

              It would use a routine like this one to return the angle: http://64.233.167.104/search?q=cache:Ra_R2faqt5IJ:www.uk-dave.com/bytes/java/angle-points.php+calculating+angle+of+two+points&hl=en&c t=clnk&cd=2&gl=us
              Is that different to the "WYS" calculation in this POC indicator (in that thread) :



              ?

              Comment


                #8
                You can't deal with angles since an angle on a chart is not absolute. For example, try drawing a 45 degree line to the x axis on a chart. Now zoom in. You will visually see that the degree of the angle has now changed.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  Absolute?

                  I am not sure what you mean.

                  For the sake of discussion, if I know the close, high, avg price, etc., that would give me a fixed X,Y coordinates for any two bars that I want to calculate an angle from. (In this example, I am assuming that the X coordinate would be centered on the bar.) I only need two fixed points to calculate an angle.

                  I was not interested in this for drawing lines, though it can be used for that as well.

                  Regardless, I am not a chart technician, so maybe this is not so useful. I was suprised that this is not used. I am also fascinated in 3D charting and cubes, but I will bite my lip until we can get simple geometry in the SDK

                  Thanks!
                  Michael

                  Comment


                    #10
                    Originally posted by moflaherty View Post
                    I only need two fixed points to calculate an angle.
                    The problem is that the X coordinates of bars are not fixed when you zoom, resize or squish/unsquish the graph.

                    Comment


                      #11
                      ?

                      I am definately not getting what you guys are saying.

                      One of my other jobs in life (I have had many) was digitizing embroidery designs, so maybe I am still in that thought process. We had X, Y, and Z coordinates to move the needle. Even though the shirt or hat moved or was hooped differently each time, the relationship between point A and point B was relatively fixed.

                      Using that as an example, if I have a close price, that is fixed. When I have two bars, in the code, they have an X-Y relationship no matter what the drawing space coordinates are. That is what I meant by 'fixed.' They have a relationship that is always the same. Close prices (as an example) do not change. The number of bars (X coordinates) do not change. So if I ask for an angle between two specific bars, that calculation would always be the same no matter where they are displayed. If I ask for an angle between the current bar close and say two back, my X coordinate (close price) will always have the same relationship. But on each change of the bar, the angle changes. Still a relative, fixed coordinate.

                      If the concern is graphical, then NT could consider how VB or .NET handles coordinate conversions when using drawing containers. That could also be added to the SDK.

                      Maybe I am missing something (and I apologize if I am because I am new to this), but this seems useful to performing specific chart caculations. I agree with someone below that this information can certainly be programmed outside a SDK. It is no big deal to do that. I was just commenting that I am suprised chart technicians don't use angles and analytical geometry in general when determining trends and moves. That seems basic and obvious to me, and if degrees are not part of that science, then I have a lot to learn. I just ordered Encyclopedia of Chart Patterns on Monday and will be studying the science a bit more. I am also interested in 3D charting since seeing the WPF Microsoft presentation in Jan. They were doing some amazing stock charts as examples and I see a huge opportunity in meshing 2-D charts in various ways, at least programmatically. I also saw some fascinating work being done in deep space analysis with temperature histograms that might have application to stocks too. I am sure people are experimenting or have used these approaches in stocks, but I have not seen it yet. My experience in stock charting has been with tools like this and Ameritrade's suite. Flat, 2-D, and with little control. I like NT because I can actually write code and play with it.

                      Maybe for the fun of it I will mock up some examples. This, of course, after I make enough in futures to sit around and do that.

                      Thank you for your feedback; I will stop writing on this subject to spare you my rants. Hopefully the developers are already integrating the 3.5 framework into the product.

                      Comment


                        #12
                        Originally posted by moflaherty View Post
                        Using that as an example, if I have a close price, that is fixed. When I have two bars, in the code, they have an X-Y relationship no matter what the drawing space coordinates are. That is what I meant by 'fixed.' They have a relationship that is always the same. Close prices (as an example) do not change. The number of bars (X coordinates) do not change. So if I ask for an angle between two specific bars, that calculation would always be the same no matter where they are displayed. If I ask for an angle between the current bar close and say two back, my X coordinate (close price) will always have the same relationship. But on each change of the bar, the angle changes. Still a relative, fixed coordinate.
                        Your description is defining Slope.
                        Open a chart, draw a 45 degree line, now compress the chart by dragging in the x axis left to right. You will instantly see that the degree of the line increases to a value greater than 45.
                        However, the Slope is still constant.
                        RayNinjaTrader Customer Service

                        Comment


                          #13
                          ?

                          Maybe what we have here is a descrepency on what 'grid' we are using to calculate degrees.

                          If I make changes to my drawing space, does that change my X-Y variables? For example, if X=1m and Y=close prices, they still have the exact same relative relationship no matter what I am doing with the display of the chart. Are you suggesting that in my example, X and Y changes depending how I compress or expand the drawing space?

                          If the degrees changes because someone is changing the chart dimensions, then I don't believe they are calculating degrees properly. Hopefully they don't work for NASA or the military

                          You may be absolutely (and not relatively - ha) right. I will play with it more. However, on the surface, it seems like we are talking about two grids -- the fixed relationship and the drawing space. Both have merit, but I am more interested in the actual relationship, not the displayed one.

                          Comment


                            #14
                            The relationship is unchanged by the chart settings if you calculate slope strictly by the slope definition (rise/run). The x-axis will be in increments of 1 unit and the y-axis will always represent the exact same price change no matter how your chart is setup. What you could do is use strict math principles in trig to go from the absolute slope value and calculate out absolute angle inclinations from it.
                            Last edited by NinjaTrader_JoshP; 08-23-2007, 10:26 AM.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Agreed

                              I agree; that is certainly doable with the current SDK and probably the direction I will go.

                              I am suprised, however, that this kind of math is not requested by analysts, and not built in the product.

                              If anybody else has book recommendations on reading charts, I would be interested.

                              Thanks!

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by andrewtrades, Today, 04:57 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by chbruno, Today, 04:10 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post chbruno
                              by chbruno
                               
                              Started by josh18955, 03-25-2023, 11:16 AM
                              6 responses
                              436 views
                              0 likes
                              Last Post Delerium  
                              Started by FAQtrader, Today, 03:35 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post FAQtrader  
                              Started by rocketman7, Today, 09:41 AM
                              5 responses
                              19 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X