Linear Regression Slope
LINEARREG_SLOPE calculates the slope of the linear regression line.
Method
Section titled “Method”tm.ta.linearreg_slope(source, timeperiod)Inputs
Section titled “Inputs”| Parameter | Argument type | Description | Default Value |
|---|---|---|---|
| source | pd.Series | Input data series | - |
| timeperiod | int | Number of periods for the indicator | 14 |
Outputs
Section titled “Outputs”| Output | Type |
|---|---|
| linearreg_slope | np.ndarray |
Example usage
Section titled “Example usage”import tradomate as tm
@tm.strategy()def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out Linear Regression Slope linearreg_slope = tm.ta.linearreg_slope(data.close, timeperiod=14)
# Get the last value and print last_value = linearreg_slope.iloc[-1] tm.log(f"Last value of Linear Regression Slope is {last_value}")
# Plot the values of linearreg_slope tm.plot(linearreg_slope, title="Linear Regression Slope", overlay=False)