Untitled
"TASC 2025.03 A New Solution, Removing Moving Average Lag" by PineCodersTASC, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: TASC 2025.03 A New Solution, Removing Moving Average Lag (v1.0), read 2026-10-12T15:51:02.036Z; source language v6.
Licence: Mozilla Public License 2.0 (MPL-2.0) — full text. The source is published with it, modifications included, under the same licence.
TASC 2025.03 A New Solution, Removing Moving Average Lag by PineCodersTASC, ported from Pine v6. Pane indicator with 6 plots, 1 fill, 1 level and 9 inputs.
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PineCodersTASC
// TASC Issue: March 2025
// Article: A New Solution
// Removing Moving Average Lag
// Article By: John F. Ehlers
// Language: Pine-compatible v6
// Provided By: PineCoders, for tradingview.com
// ------------------------------------------------------------------------------------------------
// Original author: PineCodersTASC
// Original title: TASC 2025.03 A New Solution, Removing Moving Average Lag
// Licence: MPL-2.0 (the header above is the original notice, kept verbatim)
// Pine version: 6
// Fetched: 2026-10-12
// Ported to FloScript by FloSignals; modifications under MPL-2.0.
// Converter: @flosignals/floscript 0.1.0, strict mode, score 100/100
// ------------------------------------------------------------------------------------------------
//@floscript=1
//@version=6
title = "TASC 2025.03 A New Solution," + " Removing Moving Average Lag"
stitle = "RMAL"
indicator(title, stitle, false)
//#region --- Constants and inputs ---
// @variable Alias for `display.none`.
SHOW_NONE = display.none
// @variable The source series to analyze.
float src = input.source(close, "Source:")
// @variable Length of series to analyze.
int length = input.int(30, "Length:")
// @variable Color input for `0`- zero-line.
color c0 = input.color(#B2B5BE, "0 line", group="Style")
// @variable Color input for `Source`.
color cSrc = input.color(#B2B5BE, "Source", group="Style")
// @variable Color input for `PMA`and `Slope`.
color cSlp = input.color(#0055ff, "PMA/Slope", group="Style")
// @variable Color input for `Prediction` line when above `PMA/Slope`.
color cPdu = input.color(#0DFF00, "Predict ", inline="p", group="Style")
// @variable Color input for `Prediction` line when below `PMA/Slope`.
color cPdd = input.color(#FF0000, "", inline="p", group="Style")
// @variable Color input for fill between `SMA`and `PMA` when `PMA` is above `SMA`.
color cFlu = input.color(#4caf50, "Fill ", inline="f", group="Style")
// @variable Color input for fill between `SMA`and `PMA` when `PMA` is below `SMA`.
color cFld = input.color(#ff5252, "", inline="f", group="Style")
//#endregion
//#region --- Functions ---
// @function Calculates the projected moving average (PMA).
// @param src Series of values to process.
// @param length Number of bars in the calculation.
// @returns A tuple containing the following values:
// - The PMA value.
// - The SMA value.
// - The linear regression slope.
pma(float src, int length) =>
float Slope = ta.linreg(src, length, 0) - ta.linreg(src, length, 1)
float SMA = ta.sma(src, length)
float PMA = SMA + Slope * length * 0.5
[PMA, SMA, Slope]
//#endregion
//#region --- Calculations
// Calculate the PMA, SMA, and slope of `src` over `length` bars.
[pma, sma, slope] = pma(src, length)
// @variable The predicted PMA.
float predictPMA = pma + 0.5 * (slope - slope[2]) * length
// @variable The predicted slope.
float predictSlp = 1.5 * slope - 0.5 * slope[4]
// @variable Cumulative average bar range.
float aRng = ta.cum(high - low) / bar_index + 1
// @variable `true` when `pma` is above `sma`.
bool above = pma > sma
// Colors
color cSl_pred = predictPMA > pma ? cPdu : cPdd
color col_pred = color.new(cSl_pred, 25)
color cSMA = color.new(chart.fg_color, 50)
color cPma = color.new(cSlp, 35)
//#endregion
//#region --- Display ---
// Plot `src`. It is invisible by default.
plot(src, "SRC", cSrc, display=SHOW_NONE, force_overlay=true)
// Plot `pma`, `predictPMA`, and `sma` in the main chart pane.
p1 = plot(pma, "PMA", cPma, 2, force_overlay=true)
plot(predictPMA, "Predict", col_pred, force_overlay=true)
p2 = plot(sma, "SMA", cSMA, force_overlay=true)
// Plot `slope`, `predictSlp`, and a horizontal 0 line in a separate pane.
plot(slope, "Slope", cSlp)
plot(predictSlp, "Slope Predict", cSl_pred)
hline(0, "0", c0)
// Fill the space between `p1` and `p2` with a gradient color.
fill(p1, p2, above ? sma + aRng * 5 : sma, above ? sma : sma - aRng * 5, above ? color.new(cFlu, 100) : color.new(cFld, 75), above ? color.new(cFlu, 75) : color.new(cFld, 100))
//#endregion
This file is under the Mozilla Public License 2.0; it is a port of the original by PineCodersTASC, with the original licence header kept and the changes made for FloScript noted in the file.
- v2
Library refresh 2026-10-14
- v1
Library refresh 2026-10-12
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.