Skip to content

Linear Regression Angle

LINEARREG_ANGLE calculates the angle of the linear regression line.

Method

tm.ta.linearreg_angle(source, timeperiod)

Inputs

ParameterArgument typeDescriptionDefault Value
sourcepd.SeriesInput data series-
timeperiodintNumber of periods for the indicator14

Outputs

OutputType
linearreg_anglenp.ndarray

Example usage

strategy.py
import tradomate as tm
@tm.strategy()
def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out Linear Regression Angle
linearreg_angle = tm.ta.linearreg_angle(data.close, timeperiod=14)
# Get the last value and print
last_value = linearreg_angle.iloc[-1]
tm.log(f"Last value of Linear Regression Angle is {last_value}")
# Plot the values of linearreg_angle
tm.plot(linearreg_angle, title="Linear Regression Angle", overlay=False)