Linear Regression with TA-Lib

The Linear Regression functions within TA-Lib are a simplification of others Linear Regression functions available through other Python Libraries. Nevertheless it could be very useful in the context of Technical Analysis of stock market indicators (Source: Image of the author)

ta.LINEARREG(series of values,timeperiod)

An example of a sample dataframe on the left and the results of the functions on the right. (Source: Image of the author)

ta.LINEARREG_SLOPE(column with y values, timeperiod):

ta.LINEARREG_INTERCEPT (column with y values, timeperiod)

ta.LINEARREG_ANGLE (column with y values, timeperiod)

Quick and dirty plot of the new series created with tje ta.LINEARREG_SLOPE function. Every point is the slope evaluated with the regression equation over all of timeperiod=10 sets of values, at x=9. (Source: Image of the author)

ta.LINEARREG_TSF (column with y values, timeperiod)

Quick and dirty plot of the new series created with ta.TSF function. Every point is the next tick(*) forecast evaluated with the regression equation over all of timeperiod=10 sets of values, at x=10. (*) tick can whatever you have in the dataframe: days, months, years, minutes… As you can see the shape of the plot is similar to the previous plot but changes the units of measures along the y axis (Source: Image of the author)

ta.CORREL(column with x values, column with y values, timeperiod)

… just Follow me

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store