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

How do you plot a linear regression trend line in NT8?

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

    How do you plot a linear regression trend line in NT8?

    How do you plot a linear regression trend line in NT8? I don't want a moving line. I want a trend line. The Linear Regression indicator plots it as a moving line. I used to be able to do this in NT, now I can't seem to be able to. Thanks!

    #2
    Hello Joseph, thanks for writing in.

    The TrendLine and Linear Regression indicators are available to study through the Indicators folder of the NinjaScript Editor. The most straight forward way of plotting a trend line for the linear regression will be to add the Trend Lines indicator to your chart, then, for the Input Series, change this from the default series to the Linear Regression indicator.

    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hello Joseph, thanks for writing in.

      The TrendLine and Linear Regression indicators are available to study through the Indicators folder of the NinjaScript Editor. The most straight forward way of plotting a trend line for the linear regression will be to add the Trend Lines indicator to your chart, then, for the Input Series, change this from the default series to the Linear Regression indicator.

      Please let me know if I can assist any further.
      Thanks! That worked for the price panel, but I neglected to mention that I need this to plot for VOL in panel 2. Also, how do you set the period of the Linear Regression line? Any ideas?
      Last edited by Joseph Connors; 12-23-2020, 11:29 AM.

      Comment


        #4
        Hello Joseph, thanks for your repy.

        Notice that when you change the Input Series of the TrendLines indicator, there is another Input Series selector within the Linear Regression indicator. Set that input series to a VOL indicator. After this set the panel of Trend Lines to the same panel number of the VOL indicator (panel 2 in my example).

        Here is an example picture of the setup:


        When selecting the Linear regression indicator as the input series, you will see there is a Period property that you can change.

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChrisL View Post
          Hello Joseph, thanks for your repy.

          Notice that when you change the Input Series of the TrendLines indicator, there is another Input Series selector within the Linear Regression indicator. Set that input series to a VOL indicator. After this set the panel of Trend Lines to the same panel number of the VOL indicator (panel 2 in my example).

          Here is an example picture of the setup:


          When selecting the Linear regression indicator as the input series, you will see there is a Period property that you can change.

          Please let me know if I can assist any further.
          Thanks! That did the trick!

          When I used to use this on vol, as I moved my chart back in time to the left it would re-calculate and display the result. I notice that this does not do that. Is there anyway that that can be done?

          Comment


            #6
            Hello Joseph, thanks for your reply.

            The only way to see historical trend lines is to add them through the properties, it will not re-calculate based on the visible bars.

            Please let me know if I can assist any further.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChrisL View Post
              Hello Joseph, thanks for your reply.

              The only way to see historical trend lines is to add them through the properties, it will not re-calculate based on the visible bars.

              Please let me know if I can assist any further.
              I'm not sure that I understand what you mean by "add them through properties"? Can you elaborate?

              Comment


                #8
                Hello Joseph, thanks for your reply.

                In the TrendLine settings there is a property called "Number of trend lines" this is how many historical trend lines are calculated.

                Please let me know if I can assist any further.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_ChrisL View Post
                  Hello Joseph, thanks for your reply.

                  In the TrendLine settings there is a property called "Number of trend lines" this is how many historical trend lines are calculated.

                  Please let me know if I can assist any further.
                  Well, thank you again for your help and very quick response! Merry Christmas to you and your family!

                  Comment


                    #10
                    Hello,

                    How can tell the indicator to stop drawing the line after X number of bars once it has broken the trend line?

                    Regards,
                    Glen.

                    Comment


                      #11
                      Hello Glen,

                      Thanks for your notes.

                      To clarify, are you using AddChartIndicator() to plot the TrendLines indicator on a chart window from the strategy?

                      Are you adding your own plot using AddPlot() in a custom NinjaScript indicator and assigning the TrendLines() indicator value to that plot?

                      Or, are you trying to modify a copy of the TrendLines indicator that comes with NinjaTrader?

                      We look forward to assisting further.
                      Brandon H.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi Brandon,

                        Thank you for your reply.

                        I am ok to make a copy of the code from the NT trend lines indicator. I am looking for what cod do I enter to tell the lines that were plotted to stop plotting at X number of bars past where the line is broken.

                        Notes 1 & 2 ) No,

                        Note 3) Or, are you trying to modify a copy of the TrendLines indicator that comes with NinjaTrader? Yes

                        Regards,
                        Glen.


                        Comment


                          #13
                          Hello KiwiTraveler,

                          Thanks for your notes.

                          The TrendLines indicator that comes with NinjaTrader uses SharpDX and OnRender() to custom render the trend lines on the chart window.

                          You would have to come up with your own custom logic to only custom render the trend lines on the chart window until the Close price crosses above/below the plot value of the indicator. And, after a certain number of bars pass since the Close price crossed above/below the plot value of the indicator, continue custom rendering the trend lines.

                          You could consider using a bool to detect if the Close price crosses above/below the plot value, such as setting a bool to false when the break occurs. You would need to use custom logic to count the number of bars that have passed since the break and flip to bool back to true.

                          The bool could then be used to determine if the trend lines should be custom-rendered on the chart or not. For example, when the bool is true, custom render the trend lines.

                          Using SharpDX for Custom Chart Rendering: https://ninjatrader.com/support/help..._rendering.htm
                          OnRender(): https://ninjatrader.com/support/help...8/onrender.htm
                          CrossAbove: https://ninjatrader.com/support/help...crossabove.htm
                          CrossBelow: https://ninjatrader.com/support/help...crossbelow.htm
                          Brandon H.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by fx.practic, 10-15-2013, 12:53 AM
                          5 responses
                          5,406 views
                          0 likes
                          Last Post Bidder
                          by Bidder
                           
                          Started by Shai Samuel, 07-02-2022, 02:46 PM
                          4 responses
                          98 views
                          0 likes
                          Last Post Bidder
                          by Bidder
                           
                          Started by DJ888, Yesterday, 10:57 PM
                          0 responses
                          8 views
                          0 likes
                          Last Post DJ888
                          by DJ888
                           
                          Started by MacDad, 02-25-2024, 11:48 PM
                          7 responses
                          160 views
                          0 likes
                          Last Post loganjarosz123  
                          Started by Belfortbucks, Yesterday, 09:29 PM
                          0 responses
                          9 views
                          0 likes
                          Last Post Belfortbucks  
                          Working...
                          X