Skip to content

Linear Regression Slope ​

Bar-to-bar change of the least-squares line.

Kind indicator · Drawn in its own pane

Try it ​

On the chart, press / and choose Linear Regression Slope under Oscillators. To change it, copy the source below into the AlphaScript editor.

Inputs ​

InputTypeDefault
Lengthint14
Sourcesource"close"
Colorcolor"#2962FF"

Source ​

From packages/alphascript/indicators/lrslope.as.js.

js
indicator({ name: "Linear Regression Slope", shortTitle: "LRS", overlay: false, precision: 6 });
const length = input.int("Length", 14, { min: 2 });
const src = input.source("Source", "close");
plot(ta.calc([ta.linreg(src, length, 0), ta.linreg(src, length, 1)], (a, b) => a - b), { title: "Slope", color: input.color("Color", "#2962FF", { group: "Style" }) });
hline(0, { title: "Zero", color: "rgba(120,123,134,0.5)", style: "dashed" });

AlphaScript language v0.1 · runtime 0.2.0