Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Linear Reg Slope Calculation

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

    Linear Reg Slope Calculation

    I am not literate in code so I work out of Excel when back-testing various strategies. I am working with changes in linear regression slope for predictive modeling but can't get the slope of linear regression in Excel to match the values in NT, and therefore can't back-test. Is there a way to download historical data WITH indicator values as well? If not, can someone provide the correct formula for the linear regression slope? Any help would be much appreciated.

    #2
    You can use the SLOPE function in Microsoft Excel​

    Comment


      #3
      Hello out of the money,

      You can write indicator values, or any values accessible in NinjaScript, to a text file or a .cvs file using StreamWriter.

      Below is a link to a reference sample that demonstrates writing information to file.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        The indicator "LinRegSlope" is not showing in fact the slope of the LinReg curve. ​When the LinReg curve is going strongly Up or Down, the absolute value of the slope should be a relatively big number, and in any case greater than during the periods when the LinReg curve is closer to a nearly horizontal line. That is obviously not happening in the embedded indicator "LinRegSlope", as we can see plotting the indicator on a chart.

        Terminology can be misleading here:
        The slope of the LinReg curve is something different from the Slope of the straight line representing the linear regression of the data i.e. close().
        The first is what I am talking about. The latter is what is shown by the indicator "LinRegSlope".

        For this reason I would propose using the value :

        LinReg(i)[0]-LinReg(i)[1] (where i represents the period parameter of the indicator LinReg)

        as a more reliable approximation for the real current slope of the LinReg curve, in case someone needs to use this slope in a Strategy.
        Be careful of the signs (+/-) though. The above formula can give positive and negative values.
        Last edited by KonstantinosNT; 01-11-2023, 07:20 AM.

        Comment


          #5
          Thanks all, I’ll give these a look next week. Good to know that it’s not actually the slope of the linear regression line at a given point in time, that is probably what caused some frustration.

          Comment


            #6
            Regarding the formulas of Lin Reg, as it is stated in the NT Help :

            " You can view this indicator method source code by selecting the menu New > NinjaScript Editor > Indicators within the NinjaTrader Control Center window.​ "
            Last edited by KonstantinosNT; 02-08-2023, 01:42 AM.

            Comment


              #7
              Originally posted by KonstantinosNT View Post
              Regarding the formulas of Lin Reg, as it is stated in the NT Help :

              " You can view this indicator method source code by selecting the menu New > NinjaScript Editor > Indicators within the NinjaTrader Control Center window.​ "
              I appreciate it again. I am not literate in code but this may be a good starting opportunity.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by sastrades, 05-10-2024, 09:59 AM
              3 responses
              54 views
              0 likes
              Last Post rc5781
              by rc5781
               
              Started by guyonabuffalo, Yesterday, 10:01 PM
              2 responses
              18 views
              0 likes
              Last Post guyonabuffalo  
              Started by thumper57, Yesterday, 04:30 PM
              5 responses
              15 views
              0 likes
              Last Post thumper57  
              Started by reynoldsn, 05-10-2024, 07:04 PM
              5 responses
              27 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by llanqui, Today, 11:10 AM
              1 response
              16 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Working...
              X