Rolling Linear Regression Channel
"Rolling Linear Regression Channel" by alexgrover, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: Rolling Linear Regression Channel (v1.0), read 2026-11-15T18:35:18.983Z; source language v4.
Licence: Mozilla Public License 2.0 (MPL-2.0) — full text. The source is published with it, modifications included, under the same licence.
Rolling Linear Regression Channel by alexgrover, ported from Pine v4. Overlay indicator with 2 plots, 1 fill and 4 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// (Notice added by FloSignals: the author's source carries none. It was published open-source on 2020-07-02; since 2019-07-26 the platform it was published on has released such a script under MPL-2.0 automatically.)
// This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License https://creativecommons.org/licenses/by-sa/4.0/
// © alexgrover
// ------------------------------------------------------------------------------------------------
// Original author: alexgrover
// Original title: Rolling Linear Regression Channel
// Licence: MPL-2.0 (the notice above was added by FloSignals; the original carries none)
// Pine version: 4
// Fetched: 2026-11-15
// Ported to FloScript by FloSignals; modifications under MPL-2.0.
// Converter: @flosignals/floscript 0.1.0, strict mode, score 100/100
// ------------------------------------------------------------------------------------------------
//@floscript=1
//@version=5
// Converted by the FloScript converter from a Pine-compatible v4 source.
indicator("Rolling Linear Regression Channel", "RLRC", true)
length = input(100)
mult = input(2)
src = input(close)
gradient = input(true)
//------------------------------------------------------------------------------
a = ta.wma(src, length)
b = ta.sma(src, length)
A = 4 * b - 3 * a
B = 3 * a - 2 * b
m = (A - B) / (length - 1)
//------------------------------------------------------------------------------
d = 0.
for i = 0 to length - 1
l = B + m * i
d := d + math.pow(src[i] - l, 2)
rmse = math.sqrt(d / (length - 1)) * mult
//------------------------------------------------------------------------------
upper = B + rmse
lower = B - rmse
os = (src - lower) / (upper - lower) * 100
//------------------------------------------------------------------------------
grad = os < 10 ? #ff1100 : math.max(os, 10) < 20 ? #d12033 : math.max(os, 20) < 30 ? #bd2649 : math.max(os, 30) < 40 ? #a72d61 : math.max(os, 40) < 50 ? #913479 : math.max(os, 50) < 60 ? #743d99 : math.max(os, 60) < 70 ? #5945b6 : math.max(os, 70) < 80 ? #494ac7 : math.max(os, 80) < 90 ? #3750db : #2157f3
//------------------------------------------------------------------------------
css = gradient ? grad : na
up = plot(upper, "upper", #2157f3, 2)
dn = plot(lower, "lower", #ff1100, 2)
fill(up, dn, color.new(css, 80))
This file is under the Mozilla Public License 2.0; it is a port of the original by alexgrover, with the original licence header kept and the changes made for FloScript noted in the file.
- v1
Library refresh 2026-11-15
Disclaimer. Scripts are written and published by members, or ported by FloSignals from open-source originals, and are their authors' own work and opinion. FloSignals does not review them for correctness and nothing in a script is financial advice or a recommendation to buy or sell anything — read the Risk Disclaimer. Posting here is under the Community Rules; a script that is not the poster's to post can be reported as the Copyright & Takedowns page says.

Comments (0)
No comments yet. Members can leave one.