Skip to content
Pine v6Open-source indicator by AlgoAlpha(opens the script page on TradingView in a new tab)

Read the trend, not the noise.

The Smoothed Gaussian Trend Filter runs price through a multi-pole Gaussian filter, flattens it with linear regression and checks it against an ATR trailing stop. You get one calm line that changes color only when the trend really turns.

  • Free and open source
  • Any symbol, any timeframe
  • Three built-in alerts
  • Five-timeframe trend table

Live demo

Running on real prices right now

Every candle color, line segment and label below comes from the indicator's own formulas. Switch markets, change the timeframe or open the settings and watch it react.

Connecting

Preparing the chart

Live Binance market data, refreshed every 15 seconds. For education only, not financial advice.

Trend across timeframes

BTC/USDT right now, exactly as the indicator's table reads it.

Reading every timeframe

  • 5m (5 minutes)Reading
  • 15m (15 minutes)Reading
  • 1h (1 hour)Reading
  • 4h (4 hours)Reading
  • 1D (1 day)Reading

AlgoAlpha - Smoothed Gaussian Trend

Inputs. Changes apply to the live chart as you edit.

Gaussian Filter Settings

Period used to calculate the Gaussian alpha.

Order of the Gaussian filter, affects smoothness. From 1 to 4.

Smoothing Settings

Length for linear regression smoothing applied on the gaussian line.

Offset for flattening the output, making it less wavy.

Extra Timeframes

Shows the multi-timeframe table in the top-right corner of the chart.

Size of the table.

Time frames

The five timeframes the table reports, in Pine notation (60 is one hour, 1D is one day).

Appearance

Highlight based on volume intensity. Strength (1 to 99) is the most a quiet bar can fade.

Enable additional buy/sell signals during trends. Choppy bars turn gray.

Enables or disables the trend bands.

Enables or disables candle coloring.

Color for bullish signals and indicators.

#00ffbb

Color for bearish signals and indicators.

#ff1100

How it works

Four steps from raw price to a clean trend

Step through the pipeline on the most recent bars of the live chart. Every line here is computed with the same formulas as the Pine Script, so you can see exactly what each stage removes.

BTC/USDT · 1h · last 120 bars

  • Close
  • Gaussian output
  • Final trend line
  • Trend and trailing stop

Loading live bars

What you see on the chart

Signals that stay quiet until they matter

One line, two colors and a label only when the trend actually turns. Everything else is optional and switches on from the indicator's inputs.

Trend flip labels

A green label prints under price when the line climbs above its trailing stop, and a red one prints over price when it drops below. Each label sits at the 14-bar extreme, so it never covers the candles it describes.

Bullish flipBearish flip

Multi-timeframe table

A compact table in the top-right corner reports the trend on five timeframes you choose, 5 minutes to 1 day by default. This one is live.

Time FrameSignal
5…
15…
60…
240…
1D…
NoteMid-trend signals disabled, 'Ranging' signals won't appear.
Optional

Mid-trend signals

When the line's slope points against its trend, bars turn gray to flag a choppy phase. A fresh label prints the moment the chop resolves back into the trend.

On by default

Volume intensity

Volume is ranked against the last 33 bars and smoothed with a 4-bar Hull average. Heavy volume makes the line and candles solid, quiet volume fades them.

Optional

Trailing bands

Gradient bands sit two average candle bodies from the line, measured over 100 bars, showing how much room the trend has before it gets tested.

On by default

Bar coloring

Candles take on the trend color, so direction is readable at a glance even when the line sits behind price.

Three alerts, ready to go

Pick any of them in TradingView's alert dialog to get notified on a flip without watching the chart. Choppy Market fires only while Mid-Trend Signals is on.

  • Bullish Signal
  • Bearish Signal
  • Choppy Market

Settings

Every input, explained

These are the defaults the indicator ships with. Try any of them on the live chart first, then copy the values into TradingView.

Gaussian Filter Settings

Gaussian LengthDefault: 15
Cutoff period of the Gaussian filter. Lower values react faster, higher values smooth more.
PolesDefault: 3 (1 to 4)
Order of the filter. More poles reject noise more sharply but add a little lag.

Smoothing Settings

Smoothing LengthDefault: 22
Number of bars in the linear regression fitted to the Gaussian line.
Flatten MultiplierDefault: 7
How many bars back the regression is read. Higher values flatten the line and remove waves, with more delay.

Extra Timeframes

Enable TableDefault: On
Shows the multi-timeframe trend table in the top-right corner.
Table SizeDefault: Tiny
Text size of the table: Tiny, Small, Medium or Large.
Time frame 1 to 5Default: 5, 15, 60, 240, 1D
The five timeframes the table reports. Any TradingView timeframe works.

Appearance

Volume Intensity HighlightingDefault: On, 70
Fades the line and candles on light volume. Strength (1 to 99) is the most a quiet bar can fade. When off, both use a fixed 50% transparency.
Mid-Trend SignalsDefault: Off
Grays out choppy bars, adds continuation labels when a choppy phase ends and enables the Choppy Market alert.
Trailing BandsDefault: Off
Draws gradient bands two average candle bodies (100-bar average) away from the line.
Bar ColorDefault: On
Paints the candles with the trend color.
Bullish ColorDefault: #00ffbb
Color of the line, candles and labels in an uptrend.
Bearish ColorDefault: #ff1100
Color of the line, candles and labels in a downtrend.

Get started

Add it to TradingView in under a minute

Paste the source into the Pine Editor for this exact version, or add AlgoAlpha's published copy straight from TradingView's community library.

  1. Step 1

    Copy the script

    Use the copy button on this page. It copies the complete source, license header included.

  2. Step 2

    Open the Pine Editor

    On any TradingView chart, open the Pine Editor. Depending on your layout it sits in the bottom panel or in the toolbar on the right.

  3. Step 3

    Paste it over the template

    From the editor's script menu choose Create new, then Indicator. Select all of the template code and paste the script over it.

  4. Step 4

    Save and add to chart

    Press Ctrl + S (or Cmd + S on a Mac) to save it to your account, then click Add to chart.

Option 1

Paste the source

Copy the full Pine Script v6 code, then follow the four steps.

Option 2

Add it from the community library

Open the Indicators menu on your chart, search for Smoothed Gaussian Trend Filter and pick the one by AlgoAlpha.

View the script page(opens in a new tab)

Each TradingView plan limits how many indicators fit on one chart. If you are at the limit, remove one before adding this.

Source

The complete Pine Script

Released by AlgoAlpha under the Mozilla Public License 2.0. You can read, use and adapt every line. Keep the license header when you share it.

smoothed-gaussian-trend.pine
Pine Script v6159 lines
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © AlgoAlpha//@version=6indicator("Smoothed Gaussian Trend Filter [AlgoAlpha]", "AlgoAlpha - Smoothed Gaussian Trend", overlay = true) periodInput = input.int(15, title="Gaussian Length", tooltip="Period used to calculate the Gaussian alpha.", group = "Gaussian Filter Settings")polesInput = input.int(3, title="Poles", minval=1, maxval=4, tooltip="Order of the Gaussian filter, affects smoothness.", group = "Gaussian Filter Settings")linreglen = input.int(22, title="Smoothing Length", tooltip="Length for linear regression smoothing applied on the gaussian line.", group = "Smoothing Settings")linregoffset = input.int(7, title="Flatten Multiplier", tooltip="Offset for flattening the output, making it less wavey.", group = "Smoothing Settings") en_table = input.bool(true, title="Enable Table", tooltip="Enables/Disables the table.", group = "Extra Timeframes")table_size = input.string("Tiny", title="Table Size", options = ["Tiny", "Small", "Medium", "Large"], tooltip="Size of the table.", group = "Extra Timeframes")t1 = input.timeframe("5", "Time frame 1", group = "Extra Timeframes")t2 = input.timeframe("15", "Time frame 2", group = "Extra Timeframes")t3 = input.timeframe("60", "Time frame 3", group = "Extra Timeframes")t4 = input.timeframe("240", "Time frame 4", group = "Extra Timeframes")t5 = input.timeframe("1D", "Time frame 5", group = "Extra Timeframes") vol_int = input.bool(true, title="", tooltip="Highlight based on volume intensity.", group = "Appearance", inline = "vol")vol_filt = input.int(70, title="Volume Intensity Highlighting Strength", minval=1, maxval=99, tooltip="Adjusts sensitivity to volume changes.", group = "Appearance", inline = "vol")mid_trnd_sig = input.bool(false, title=" Mid-Trend Signals", tooltip="Enable additional buy/sell signals during trends.", group = "Appearance")bands = input.bool(false, title=" Trailing Bands", tooltip="Enables/Disables Trend Bands", group = "Appearance")barcol = input.bool(true, title=" Bar Color", tooltip="Enables/Disables Candle Colouring", group = "Appearance")green = input.color(#00ffbb, title="Bullish Color", tooltip="Color for bullish signals and indicators.", group = "Appearance")red = input.color(#ff1100, title="Bearish Color", tooltip="Color for bearish signals and indicators.", group = "Appearance") calcGaussianAlpha(_length, _order) =>    freq = (2.0 * math.pi) / _length    factorB = (1.0 - math.cos(freq)) / (math.pow(1.414, (2.0 / _order)) - 1.0)    alphaVal = -factorB + math.sqrt(factorB * factorB + 2.0 * factorB)    alphaVal gaussianSmooth(dataIn, filterLevel, alphaCoeff) =>    var float runningFilterValue = 0.0    oneMinusAlpha = 1.0 - alphaCoeff    alphaSquared  = alphaCoeff * alphaCoeff    alphaCubed    = alphaCoeff * alphaCoeff * alphaCoeff    alpha4        = alphaCoeff * alphaCoeff * alphaCoeff * alphaCoeff    omaSquared    = oneMinusAlpha * oneMinusAlpha    omaCubed      = omaSquared * oneMinusAlpha    oma4          = omaCubed * oneMinusAlpha     if filterLevel == 1        runningFilterValue := alphaCoeff * dataIn +                              oneMinusAlpha * nz(runningFilterValue[1])    else        if filterLevel == 2            runningFilterValue := alphaSquared * dataIn                                  + 2.0 * oneMinusAlpha * nz(runningFilterValue[1])                                  - omaSquared * nz(runningFilterValue[2])        else            if filterLevel == 3                runningFilterValue := alphaCubed * dataIn                                      + 3.0 * oneMinusAlpha * nz(runningFilterValue[1])                                      - 3.0 * omaSquared * nz(runningFilterValue[2])                                      + omaCubed * nz(runningFilterValue[3])            else                if filterLevel == 4                    runningFilterValue := alpha4 * dataIn                                          + 4.0 * oneMinusAlpha * nz(runningFilterValue[1])                                          - 6.0 * omaSquared * nz(runningFilterValue[2])                                          + 4.0 * omaCubed * nz(runningFilterValue[3])                                          - oma4 * nz(runningFilterValue[4])    runningFilterValue pine_supertrend(src, factor, atrPeriod) =>    atr = ta.atr(atrPeriod)    upperBand = src + factor * atr    lowerBand = src - factor * atr    prevLowerBand = nz(lowerBand[1])    prevUpperBand = nz(upperBand[1])    lowerBand := lowerBand > prevLowerBand or src[1] < prevLowerBand ? lowerBand : prevLowerBand    upperBand := upperBand < prevUpperBand or src[1] > prevUpperBand ? upperBand : prevUpperBand    int _direction = na    float superTrend = na    prevSuperTrend = superTrend[1]    if na(atr[1])        _direction := 1    else if prevSuperTrend == prevUpperBand        _direction := src > upperBand ? -1 : 1    else        _direction := src < lowerBand ? 1 : -1    superTrend := _direction == -1 ? lowerBand : upperBand    [superTrend, _direction] tableSize(table_size) =>	switch table_size		"Tiny"                   => size.tiny		"Small"                  => size.small		"Medium"                 => size.normal		"Large"                  => size.large alphaValue = calcGaussianAlpha(periodInput, polesInput)gmaOutput = gaussianSmooth(close, polesInput, alphaValue)final = ta.linreg(gmaOutput, linreglen, linregoffset) [ST, dir] = pine_supertrend(final, 0.15, 21)trend = final > final[1] ? 1 : -1trend1 = final > ST ? 1 : -1ranging = (trend * trend1 < 0) z = 33s_vol = ta.hma((volume - ta.lowest(volume, z)) / (ta.highest(volume, z) - ta.lowest(volume, z)), 4)transparency_ = math.min(100 - s_vol * 100, vol_filt)dist = ta.sma(math.abs(close - open), 100) main = plot(final, color=ranging and mid_trnd_sig ? color.gray : trend1 > 0 ? color.new(green, vol_int ? transparency_ : 50) : color.new(red, vol_int ? transparency_ : 50), linewidth=3)bull = plot(trend1 > 0 ? final - dist * 2 : na, style=plot.style_linebr, color=color.new(green, 90), display = bands ? display.all : display.none)bear = plot(trend1 < 0 ? final + dist * 2 : na, style=plot.style_linebr, color=color.new(red, 90), display = bands ? display.all : display.none)fill(main, bull, final, final - dist * 2, color.new(ranging and mid_trnd_sig ? color.gray : green, vol_int ? transparency_ : 50), color.new(ranging and mid_trnd_sig ? color.gray : green, 93), display = bands ? display.all : display.none)fill(main, bear, final + dist * 2, final, color.new(ranging and mid_trnd_sig ? color.gray : red, 93), color.new(ranging and mid_trnd_sig ? color.gray : red, vol_int ? transparency_ : 50), display = bands ? display.all : display.none) h = math.max(ta.highest(14), ta.highest(final, 14), final + dist * 2)l = math.min(ta.lowest(14), ta.lowest(final, 14), final - dist * 2) plotshape(trend1 > 0 and (mid_trnd_sig ? not ranging and ranging[1] : trend1[1] < 0) ? l : na, title="Bullish Signal", style=shape.labelup, location=location.absolute, size=size.small, color=green)plotshape(trend1 < 0 and (mid_trnd_sig ? not ranging and ranging[1] : trend1[1] > 0) ? h : na, title="Bearish Signal", style=shape.labeldown, location=location.absolute, size=size.small, color=red) barcolor(barcol ? ranging and mid_trnd_sig ? color.gray : trend1 > 0 ? color.new(green, vol_int ? transparency_ : 50) : color.new(red, vol_int ? transparency_ : 50) : na, title = "Bar Coloring") s1 = request.security(syminfo.tickerid, t1, ranging and mid_trnd_sig ? 0 : trend1 > 0 ? 1 : -1)s2 = request.security(syminfo.tickerid, t2, ranging and mid_trnd_sig ? 0 : trend1 > 0 ? 1 : -1)s3 = request.security(syminfo.tickerid, t3, ranging and mid_trnd_sig ? 0 : trend1 > 0 ? 1 : -1)s4 = request.security(syminfo.tickerid, t4, ranging and mid_trnd_sig ? 0 : trend1 > 0 ? 1 : -1)s5 = request.security(syminfo.tickerid, t5, ranging and mid_trnd_sig ? 0 : trend1 > 0 ? 1 : -1) s1a = s1 == 1 ? "Bullish" : s1 == -1 ? "Bearish" : "Ranging"s2a = s2 == 1 ? "Bullish" : s2 == -1 ? "Bearish" : "Ranging "s3a = s3 == 1 ? "Bullish" : s3 == -1 ? "Bearish" : "Ranging"s4a = s4 == 1 ? "Bullish" : s4 == -1 ? "Bearish" : "Ranging"s5a = s5 == 1 ? "Bullish" : s5 == -1 ? "Bearish" : "Ranging" if barstate.islast and en_table    var data_table = table.new(position=position.top_right, columns=2, rows=mid_trnd_sig ? 6 : 7, bgcolor=chart.bg_color, border_width=1, border_color=chart.fg_color, frame_color=chart.fg_color, frame_width=1)    table.cell(data_table, text_halign=text.align_center, column=0, row=0, text="Time Frame", text_color=chart.fg_color, text_size=tableSize(table_size))    table.cell(data_table, text_halign=text.align_center, column=1, row=0, text="Signal", text_color=chart.fg_color, text_size=tableSize(table_size))     table.cell(data_table, text_halign=text.align_center, column=0, row=1, text=t1, text_color=chart.fg_color, text_size=tableSize(table_size))    table.cell(data_table, text_halign=text.align_center, column=1, row=1, text=s1a, text_color=chart.fg_color, bgcolor=s1a == "Bullish" ? color.new(green, 70) : s1a == "Bearish" ? color.new(red, 70) : color.new(color.gray, 70), text_size=tableSize(table_size))     table.cell(data_table, text_halign=text.align_center, column=0, row=2, text=t2, text_color=chart.fg_color, text_size=tableSize(table_size))    table.cell(data_table, text_halign=text.align_center, column=1, row=2, text=s2a, text_color=chart.fg_color, bgcolor=s2a == "Bullish" ? color.new(green, 70) : s2a == "Bearish" ? color.new(red, 70) : color.new(color.gray, 70), text_size=tableSize(table_size))     table.cell(data_table, text_halign=text.align_center, column=0, row=3, text=t3, text_color=chart.fg_color, text_size=tableSize(table_size))    table.cell(data_table, text_halign=text.align_center, column=1, row=3, text=s3a, text_color=chart.fg_color, bgcolor=s3a == "Bullish" ? color.new(green, 70) : s3a == "Bearish" ? color.new(red, 70) : color.new(color.gray, 70), text_size=tableSize(table_size))     table.cell(data_table, text_halign=text.align_center, column=0, row=4, text=t4, text_color=chart.fg_color, text_size=tableSize(table_size))    table.cell(data_table, text_halign=text.align_center, column=1, row=4, text=s4a, text_color=chart.fg_color, bgcolor=s4a == "Bullish" ? color.new(green, 70) : s4a == "Bearish" ? color.new(red, 70) : color.new(color.gray, 70), text_size=tableSize(table_size))     table.cell(data_table, text_halign=text.align_center, column=0, row=5, text=t5, text_color=chart.fg_color, text_size=tableSize(table_size))    table.cell(data_table, text_halign=text.align_center, column=1, row=5, text=s5a, text_color=chart.fg_color, bgcolor=s5a == "Bullish" ? color.new(green, 70) : s5a == "Bearish" ? color.new(red, 70) : color.new(color.gray, 70), text_size=tableSize(table_size))     if not mid_trnd_sig        table.cell(data_table, text_halign=text.align_center, column=0, row=6, text="Note", text_color=chart.fg_color, text_size=tableSize(table_size))        table.cell(data_table, text_halign=text.align_center, column=1, row=6, text="Mid-trend signals disabled, 'Ranging' signals won't appear.", text_color=chart.fg_color, text_size=tableSize(table_size)) alertcondition(trend1 > 0 and (mid_trnd_sig ? not ranging and ranging[1] : trend1[1] < 0), title="Bullish Signal", message="Bullish signal triggered.")alertcondition(trend1 < 0 and (mid_trnd_sig ? not ranging and ranging[1] : trend1[1] > 0), title="Bearish Signal", message="Bearish signal triggered.")alertcondition(ranging and mid_trnd_sig, title="Choppy Market", message="Choppy market conditions detected.")

The copy button always copies the full script, license header included, ready to paste into the Pine Editor.

Alerts

Let the chart tap you on the shoulder

The script ships with three alert conditions, so you can step away from the screen and still catch every flip.

  1. 1Add the indicator to your chart.
  2. 2Open the alert dialog with the alarm clock icon in the top toolbar, or press Alt + A.
  3. 3Set the condition to AlgoAlpha - Smoothed Gaussian Trend and choose one of its three signals.
  4. 4Set it to trigger Once Per Bar Close for confirmed signals, then create the alert.
  • Bullish Signal

    Fires when the trend flips up. With Mid-Trend Signals on, it fires instead when a choppy phase ends with the trend pointing up.

    Alert message: Bullish signal triggered.

  • Bearish Signal

    Fires when the trend flips down. With Mid-Trend Signals on, it fires instead when a choppy phase ends with the trend pointing down.

    Alert message: Bearish signal triggered.

  • Choppy Market

    Fires while the line's slope disagrees with its trend. Only available when Mid-Trend Signals is turned on.

    Alert message: Choppy market conditions detected.

FAQ

Questions traders ask first

Short answers about cost, repainting, markets and the live demo on this page.

Is the indicator free?

Yes. AlgoAlpha published it as an open-source script under the Mozilla Public License 2.0. You can use it, read every line and adapt it, as long as the license notice stays in the code.

Does it repaint?

Each value is calculated from the current bar and the bars before it, so closed bars keep their colors and labels. The bar that is still forming can change until it closes, like any live indicator, and the timeframe table follows the forming bar of each timeframe. Set alerts to Once Per Bar Close if you only want confirmed signals.

Which markets and timeframes does it work on?

Any chart TradingView can draw, including crypto, stocks, forex, futures and indices, on any timeframe. Volume intensity reads the symbol's volume, so on an instrument without volume data you can switch that input off.

What do the gray bars mean?

Gray only appears with Mid-Trend Signals turned on. It marks bars where the line's slope points against the trend, which usually means the market is moving sideways.

Can I change the timeframes in the table?

Yes. Time frame 1 to 5 in the Extra Timeframes group accept any TradingView timeframe, and Table Size scales the table from Tiny to Large. You can try both in the live settings on this page.

How is the live chart on this page made?

The page recreates the indicator's formulas and runs them on live Binance prices, with Kraken as a backup feed. Small differences from your TradingView chart can come from the data feed and from how much history each chart has loaded.

Is this financial advice?

No. The indicator is a tool for reading trend, not a promise of future returns. Test it on your own markets, combine it with your own analysis and manage your risk.

Put a calmer trend line on your chart today

Copy the script, paste it into the Pine Editor and you are one click away from seeing it on your own symbols.