Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Linear Regression Channel Slope

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

    Linear Regression Channel Slope

    I am trying to add a command into my strategy that identifies when the Linear Regression Channel goes flat or starts sloping in the opposite direction, but I cannot figure out how to make it happen.

    It seems that the Linear Regression Indicator and the Linear Regression Slope indicator are both based on how the endpoint of a regression line is changing, rather than what the slope of the whole regression line/channel is based solely on the current bar (not comparing it to the previous bar).

    Does this make sense?

    Obviously this information is in the program somewhere. I can have the strategy draw the regression channel on the chart and I can visually see the slope.

    Thanks in advance for the help!

    #2
    You can use the Slope() method to get the slope of any data series/indicator.

    http://www.ninjatrader-support.com/H...eV6/Slope.html
    RayNinjaTrader Customer Service

    Comment


      #3
      Thank you.

      I probably should have explicitly mentioned that I have tried using the Slope() function, but it does not seem to be giving me the result I need.

      I have modified the LinearRegressionSlope indicator from the File Sharing section to try and get it to display the Slope() of a RegressionChannel(). This is what the code looks like:

      LRSlope.Set(Slope(RegressionChannel(Period, 2), Period, 0));

      The attached file shows what readings it is giving to me. I put a RegressionChannel on the chart, and dropped it on the first bar that the RegressionChannel goes from sloping down to sloping up. The number of bars in length that this RegressionChannel ended up being was 41. I then applied the indicator with a length of 41, and it doesn't seem to show any kind of slope reversal at all.

      What am I missing?
      Attached Files

      Comment


        #4
        Sorry I misunderstood, unfortunately I don't have any more ideas to put forth.
        RayNinjaTrader Customer Service

        Comment


          #5
          I've just hit this brickwall as well.
          I can't find a way to measure the slope "the way the regression channel looks on screen".
          Slope() doesn't work. Rising() doesn't work.
          etc[1] > etc[2] doesn't work.

          Comment


            #6
            There was an extensive thread about slope. Try searching the forums for "slope".
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              NinjaTrader knows the value!

              Thanks Josh.

              I had seen the extensive "Slope()" thread before, and I did just go re-read it, but I don't see anything in there that applies to my particular problem.

              The issue is that when you draw a regression channel, the whole thing looks completely different from bar to bar. If you simply move a regression channel forward one bar, it displays different values for past bars. This is unlike a moving average, which once the value is calculated it continues to look and stay the same forever.

              Am I making any sense?

              I know that the value I am looking for is somewhere stored in NinjaTrader! It has to know what angle the lines of the regression channel are. It's plotting them on the chart. I simply need to know where NinjaTrader stores these values and how I can access them.

              Please, can someone help saltminer and I?

              Comment


                #8
                The plots of the the reg channel are custom drawn via the Plot() method of the indicator. You can snoop around the source code to get an idea of what is happening.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  Success

                  Thanks for the tip!
                  I have created a version of the Regression Channel indicator which makes public the slopeSeries, which contains the slope data we are looking for.
                  To use it, simple ask for the value JRRegressionChannel( etc ).slopeSeries[0]
                  e.g.
                  double MySlope = JRRegressionChannel(Close,35,2).slopeSeries[0];

                  Cheers,
                  saltminer
                  Attached Files

                  Comment


                    #10
                    salt,

                    Also keep in mind that the slope you may calculate mathematically is going to be different compared to what you are seeing with your eye. The slope with your eye is scaled based on;

                    - the amount of data you have loaded on the chart.
                    - the amount of movement on the chart.

                    Think of this as the viewable angle slope, which I very different to what the calculation of (rise / run), or using y = mx + b will give you.

                    just some food for thought in your slope venture.
                    mrlogik
                    NinjaTrader Ecosystem Vendor - Purelogik Trading

                    Comment


                      #11
                      Originally posted by jvracing View Post
                      I probably should have explicitly mentioned that I have tried using the Slope() function, but it does not seem to be giving me the result I need.
                      Maybe this is because the built-in Slope() method doesn't actually return the slope. It returns the average momentum per bar in the lookback interval (basically (Close[0]-Close[N])/N). If you want the actual slope of a regression line, see the LinRegSlopeSFX indicator in the file sharing area.
                      -Alex

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by condorhero, Today, 09:28 PM
                      0 responses
                      6 views
                      0 likes
                      Last Post condorhero  
                      Started by MaraAnkh, Today, 08:44 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post MaraAnkh  
                      Started by wooofad, Today, 05:38 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post wooofad
                      by wooofad
                       
                      Started by caacapital, Today, 10:10 AM
                      2 responses
                      18 views
                      0 likes
                      Last Post caacapital  
                      Started by DiverG20, Today, 10:23 AM
                      0 responses
                      25 views
                      0 likes
                      Last Post DiverG20  
                      Working...
                      X