Indicator · Pine Script v6 · On the chart

Dynamic Support Line

by rubbermetal· code credited to claygrace74

Dynamic Support Line plots a composite moving average built by averaging six moving average types, then smoothing the result, with upper and lower bands set by a standard deviation multiplier.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code78
Settings8inputs
LicenceMPL-2.0
Last update4 months ago10 Jun 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

78 lines of Pine Script v6 from Dynamic Support Line.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

Dynamic Support Line.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © claygrace74

//@version=6
indicator("Dynamic Support Line", shorttitle="DSL", overlay=true)
import TradingView/ta/8

// ==================== Settings ====================
var ma_group = "Moving Average Settings"
src       = input.source(ohlc4, "Source", group=ma_group)
maLen     = input.int(5, "MA Length", minval=1, group=ma_group)
stdLen    = input.int(14, "StdDev Length", minval=1, group=ma_group)
stdMult   = input.float(1.786, "Band Multiplier", minval=0.1, step=0.1, group=ma_group)

var disp_group = "Display Settings"
i_showFill    = input.bool(true, "Show Band Fill", group=disp_group)
i_showSignals = input.bool(true, "Show Bounce/Break Signals", group=disp_group)
midColor      = input.color(color.white, "Mid Line Color", group=disp_group)
bandColor     = input.color(color.rgb(25, 0, 253), "Band Color", group=disp_group)

// ==================================================================================
// Core Calculations — composite MA from 6 types
// ==================================================================================
sma_top  = ta.sma(src, maLen)
ema_top  = ta.ema(src, maLen)
rma_top  = ta.rma(src, maLen)
hma_top  = ta.hma(src, maLen)
tema_top = ta.tema(src, maLen)
swma_top = ta.swma(src)

ma_mid    = ta.sma((ema_top + sma_top + rma_top + hma_top + tema_top + swma_top) / 6, maLen)
deviation = ta.stdev(src, stdLen) * stdMult
ma_top    = ma_mid + deviation
ma_bottom = ma_mid - deviation

// ==================================================================================
// Signals
// ==================================================================================

// Price relationship to bands
aboveMid = close > ma_mid
belowMid = close < ma_mid

// Bounce signals — price touches band and reverses
bullBounce = low <= ma_bottom and close > ma_bottom and close > open
bearBounce = high >= ma_top and close < ma_top and close < open

// Break signals — price closes beyond band
bullBreak = close > ma_top and close[1] <= ma_top[1]
bearBreak = close < ma_bottom and close[1] >= ma_bottom[1]

// ==================================================================================
// Plots
// ==================================================================================
pTop = plot(ma_top, "Upper Band", color=bandColor, linewidth=1)
pMid = plot(ma_mid, "Mid Line", color=midColor, linewidth=2)
pBot = plot(ma_bottom, "Lower Band", color=bandColor, linewidth=1)

// Dynamic fill — green when price above mid, red when below
fillColor = i_showFill ? (aboveMid ? color.new(color.green, 88) : color.new(color.red, 88)) : color(na)
fill(pTop, pMid, color=fillColor, title="Upper Fill")
fill(pMid, pBot, color=fillColor, title="Lower Fill")

// Bounce/break signals
plotshape(i_showSignals and bullBounce, style=shape.triangleup,   location=location.belowbar, color=color.green,  text="Bounce", textcolor=color.green, size=size.tiny, title="Bull Bounce")
plotshape(i_showSignals and bearBounce, style=shape.triangledown, location=location.abovebar, color=color.red,    text="Bounce", textcolor=color.red,   size=size.tiny, title="Bear Bounce")
plotshape(i_showSignals and bullBreak,  style=shape.triangleup,   location=location.belowbar, color=color.lime,   text="Break",  textcolor=color.lime,  size=size.small, title="Bull Break")
plotshape(i_showSignals and bearBreak,  style=shape.triangledown, location=location.abovebar, color=color.orange,  text="Break",  textcolor=color.orange, size=size.small, title="Bear Break")

// ==================================================================================
// Alert Conditions
// ==================================================================================
alertcondition(bullBounce, "Bullish Bounce",     "Price bounced off lower dynamic support band")
alertcondition(bearBounce, "Bearish Bounce",     "Price bounced off upper dynamic resistance band")
alertcondition(bullBreak,  "Bullish Breakout",   "Price closed above upper dynamic band")
alertcondition(bearBreak,  "Bearish Breakdown",  "Price closed below lower dynamic band")
alertcondition(ta.crossover(close, ma_mid),  "Cross Above Mid", "Price crossed above dynamic mid line")
alertcondition(ta.crossunder(close, ma_mid), "Cross Below Mid", "Price crossed below dynamic mid line")

Overview

The fill turns green when price is above the mid line and red below it. Optional markers flag bounces off a band and closes beyond a band. Settings control the average length, deviation length, band multiplier and colors. It draws on the price chart.

Details

Published by

rubbermetal on GitHub

Code credit

claygrace74, 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.

Settings

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

SettingTypeDefaultVariable
Sourcesourceohlc4src
MA Lengthint5maLen
StdDev Lengthint14stdLen
Band Multiplierfloat1.786stdMult
Show Band Fillbooltruei_showFill
Show Bounce/Break Signalsbooltruei_showSignals
Mid Line Colorcolorcolor.whitemidColor
Band Colorcolorcolor.rgb(25, 0, 253)bandColor
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

Hampel Filter

by everget
947 stars

The Hampel Filter indicator identifies and filters out price outliers to smooth price data directly on the main chart. It calculates the rolling median and Median Absolute Deviation (MAD) of the chosen source series over a specified length. When a data point e

Indicator v4 Moving averagesVolatility & bands
Updated 12 days ago · GPL-3.0 GitHub repository of Hampel Filter

This overlay indicator plots a Supertrend from an ATR length and factor, four exponential moving averages, and a selectable VWAP or TWAP taken from a chosen timeframe on the price chart. It also shows MACD and stochastic with adjustable lengths, smoothing, ver

Indicator v5 Oscillators & momentumMoving averages
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup: Vijay Thakare Option Buying Scalping Setup

This indicator plots trade entry and exit signals on the price chart by combining Bollinger Bands with optional filter conditions. It calculates standard Bollinger Bands along with RSI, Aroon, and moving average filters. Reversal signals trigger when price bre

Indicator v4 Volatility & bandsOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Bollinger Bands Winner IND [Alorse]
318 stars

This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B

Indicator v5 Moving averagesTrend
Updated 2 months ago · MIT GitHub repository of Multiple Moving Averages

NVDA Trend Ribbon

by longsurf-ai
280 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated 3 days ago · MIT GitHub repository of NVDA Trend Ribbon

Algo AVT

by ricardosantos79
261 stars

This indicator calculates an outlier-filtered moving average based on statistical filtering concepts. It stores close prices in a rolling array over a user-defined length, calculates the mean and standard deviation, and excludes values falling within a specifi

Indicator v4 Moving averagesVolatility & bands
Updated 4 years ago · None stated GitHub repository of Algo AVT

More Moving averages 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