Indicator · Pine Script v5 · On the chart

Predictive Channels [LuxAlgo]

by theonetrade· code credited to LuxAlgo

This indicator calculates and plots dynamic adaptive channel bands around price directly on the main chart.

View on GitHub

GitHub stars34on the repository
Pine versionv5runs as is
Lines of code63
Settings9inputs
LicenceMIT
Last update2 weeks ago8 Nov 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

63 lines of Pine Script v5 from assets/indicator/bit-exact/predictive_channels_luxalgo_U8SB8fWq.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

predictive_channels_luxalgo_U8SB8fWq.pine
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo

//@version=5
indicator("Predictive Channels [LuxAlgo]", "LuxAlgo - Predictive Channels", overlay = true)
//-----------------------------------------------------------------------------}
//Settings
//-----------------------------------------------------------------------------{
mult  = input.float(5, 'Factor', minval = 0)
slope = input.float(50, minval = 0) * mult

//Style
r2Css = input(#f23645, 'Upper Resistance', inline = 'resistance', group = 'Colors')
r1Css = input(color.new(#f23645, 50), 'Lower', inline = 'resistance', group = 'Colors')

s1Css = input(color.new(#089981, 50), 'Upper Support    ', inline = 'support', group = 'Colors')
s2Css = input(#089981, 'Lower', inline = 'support', group = 'Colors')

avgCss = input(#787b86, 'Average', group = 'Colors')

areaBull = input(color.new(#089981, 80), 'Fill', inline = 'area', group = 'Colors')
areaBear = input(color.new(#f23645, 80), '', inline = 'area', group = 'Colors')

//-----------------------------------------------------------------------------}
//Calculation
//-----------------------------------------------------------------------------{
var pc_avg = close
var os = 1
var hold_atr = 0.

atr = nz(ta.atr(200)) * mult

pc_avg := math.abs(close - pc_avg) > atr ? close 
  : pc_avg + os * hold_atr / slope

hold_atr := pc_avg == close ? atr / 2 : hold_atr
os := pc_avg > pc_avg[1] ? 1 : pc_avg < pc_avg[1] ? -1 : os

pc_R2 = pc_avg + hold_atr
pc_R1 = pc_avg + hold_atr/2
pc_S1 = pc_avg - hold_atr/2
pc_S2 = pc_avg - hold_atr

//-----------------------------------------------------------------------------}
//Plot
//-----------------------------------------------------------------------------{
plot_0 = plot(close, color = na, display = display.none, editable = false)

//SR PLots
plot(pc_R2, 'Upper Resistance', close == pc_avg ? na : r2Css)
plot(pc_R1, 'Lower Resistance', close == pc_avg ? na : r1Css)

plot_avg = plot(pc_avg, 'Average', close == pc_avg ? na : avgCss)

plot(pc_S1, 'Upper Support', close == pc_avg ? na : s1Css)
plot(pc_S2, 'Lower Support', close == pc_avg ? na : s2Css)

//Fill
topcss = close > pc_avg ? areaBull : color.new(chart.bg_color, 100)
btmcss = close < pc_avg ? areaBear : color.new(chart.bg_color, 100)
fill(plot_0, plot_avg, pc_R2, pc_S2, topcss, btmcss)

//-----------------------------------------------------------------------------}

Overview

Predictive Channels [LuxAlgo] tracks a central average line that adjusts along a fixed slope and resets whenever price exceeds an ATR-based threshold. Based on this center line and stored ATR values, it projects two resistance levels and two support levels, along with conditional background fills indicating bullish or bearish alignment. Main settings include the ATR multiplier factor and the slope divisor.

Details

Published by

theonetrade on GitHub

Code credit

LuxAlgo, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Factorfloat5mult
slopefloat50slope
Upper Resistancecolor#f23645r2Css
Lowercolorcolor.new(#f23645, 50)r1Css
Upper Support colorcolor.new(#089981, 50)s1Css
Lowercolor#089981s2Css
Averagecolor#787b86avgCss
Fillcolorcolor.new(#089981, 80)areaBull
areaBearcolorcolor.new(#f23645, 80)areaBear
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

[RS]Donchian Fans

by ricardosantos79
261 stars

This indicator plots Donchian Channel boundary lines along with dynamic fan projections directly on the price chart. It calculates the highest high, lowest low, and median price over a customizable lookback period. Whenever price establishes a new channel high

Indicator v4 Support & resistanceTrend
Updated 5 years ago · None stated GitHub repository of [RS]Donchian Fans

Dynamic Linear Regression

by TradersPost
228 stars

Dynamic Linear Regression calculates and plots linear regression trendlines and standard deviation channels directly on the price chart over a user-selected time period. Traders can configure static channels locked at the end time, dynamic channels that contin

Indicator v6 TrendSupport & resistance
Updated 4 months ago · None stated GitHub repository of Dynamic Linear Regression

ATR Trailing Stop

by mihakralj
99 stars

Calculates an ATR-based trailing stop overlaid on the price chart to assist with trend identification and stop placement. Using a specified ATR period and multiplier, it projects upper and lower bounds around the closing price. The stop line ratchets up during

Indicator v5 TrendVolatility & bands
Updated 8 weeks ago · Apache-2.0 GitHub repository of ATR Trailing Stop

Moon Dev Lunar Sniper

by moondevonyt
98 stars

Moon Dev Lunar Sniper is a multi-indicator overlay that scores confluence across fast and slow EMAs, RSI, MACD, DMI, and BB width to fire signals only when score meets the minimum threshold. It plots buy and sell signals on the price chart, highlights cosmic b

Indicator v6 TrendOscillators & momentum Repaints
Updated 2 months ago · Custom licence GitHub repository of Moon Dev Lunar Sniper

SuperTrend & Pivots

by dcaoyuan
55 stars

This overlay indicator plots a SuperTrend line on the price chart using a fixed ATR length of 10 and a factor of 3. When the trend direction is up it draws a green line and a light green fill toward the candle midpoint; when down it draws a red line and a ligh

Indicator v6 TrendVolatility & bands
Updated 7 months ago · Apache-2.0 GitHub repository of SuperTrend & Pivots

More Volatility & bands scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers