← Script Marketplace
Open-source scriptindicator/v1

Linear Regression

by Kodexius·@kodexius·

Plot the endpoint of a rolling least-squares line fitted to the selected source.

#regression#statistics#trend
Linear Regression chart preview

Description

Linear Regression fits a straight line to every rolling price window and displays the value of that fit at its endpoint. The resulting curve helps analysts examine statistical trend direction and changes in slope.

Open-source script. Everyone can inspect the source code, use the script on a chart, and save an editable copy.

Release notes

Version history · 1 published version

Version 1CurrentChart updatedLinear Regression · Aug 31, 2026
Release notes

Initial classic indicator release.

View current source ↓
Source codempl-2.0View source

indicator("Linear Regression", { overlay: true });
const length = input.int("Length", 14, { min: 2, max: 500 });
const source = input.source("Source", "close");
plot(linreg(source, length, 0), { title: "Linear Regression", color: "#00bcd4", lineWidth: 2 });
  

Community discussion

0 comments

Loading…

No comments yet. Start the discussion.