Indicator · Pine Script v6 · On the chart

Gaussian Filter (GAUSS)

by mihakralj

This indicator plots a Gaussian filter of a chosen price source on the price chart.

View on GitHub

GitHub stars99on the repository
Pine versionv6current
Lines of code52
Settings2inputs
LicenceApache-2.0
Last update4 weeks ago27 Sep 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

52 lines of Pine Script v6 from lib/filters/gauss/gauss.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

gauss.pine
// Licensed under the Apache License, Version 2.0
// © mihakralj
//@version=6
indicator("Gaussian Filter (GAUSS)", "GAUSS", overlay=true)

//@function Calculates Gaussian Filter using true convolution
//@param src Series to calculate Gaussian filter from
//@param sigma Standard deviation of the Gaussian kernel
//@returns Gaussian filter value
//@optimized Uses Gaussian kernel convolution with O(n) complexity per bar
gauss(series float src, simple float sigma) =>
    int kernel_size = 2 * math.ceil(3.0 * sigma) + 1
    var array<float> kernel = array.new_float(0)
    var array<float> norm_kernel = array.new_float(1, 1.0)
    var int last_kernel_size = 1
    if last_kernel_size != kernel_size
        float center = math.floor(kernel_size / 2.0)
        array.clear(kernel)
        float kernel_sum = 0.0
        for i = 0 to kernel_size - 1
            float x = i - center
            float weight = math.exp(-(x * x) / (2.0 * sigma * sigma))
            array.push(kernel, weight)
            kernel_sum += weight
        norm_kernel := array.copy(kernel)
        if kernel_sum != 0.0
            float inv_sum = 1.0 / kernel_sum
            for i = 0 to kernel_size - 1
                array.set(norm_kernel, i, array.get(kernel, i) * inv_sum)
        last_kernel_size := kernel_size
    int p = math.min(bar_index + 1, kernel_size)
    float sum = 0.0
    float weight_sum = 0.0
    for i = 0 to p - 1
        float price = src[i]
        if not na(price)
            float w = array.get(norm_kernel, i)
            sum += price * w
            weight_sum += w
    nz(sum / weight_sum, src)

// ---------- Main loop ----------

// Inputs
i_sigma = input.float(1.0, "Sigma", minval=0.1, maxval=10.0, step=0.1)
i_source = input.source(close, "Source")

// Calculation
gauss_val = gauss(i_source, i_sigma)

// Plot
plot(gauss_val, "Gaussian", color=color.yellow, linewidth=2)

Overview

Gaussian Filter (GAUSS) builds a normalized Gaussian kernel whose width follows the sigma setting, then convolves that kernel with recent bars to produce a smoothed value. Sigma controls how wide the kernel is and therefore how strongly the line smooths the source. The source input selects which series is filtered. There are no trading signals, entries, exits, or risk rules.

Details

Published by

mihakralj on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Trend

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-tradingcsharpdotnetpinescriptpythonquantitative-financesimdta-libtechnical-analysistechnical-indicators

Settings

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

SettingTypeDefaultVariable
Sigmafloat1.0i_sigma
Sourcesourceclosei_source
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

948 stars

The Adaptive Laguerre Filter calculates a smoothed, dynamically adjusted trendline plotted directly on the main price chart. It dynamically adjusts its damping factor (alpha) based on recent price range variations and median percentile calculations over a spec

Indicator v4 TrendMoving averages
Updated 10 days ago · GPL-3.0 GitHub repository of Adaptive Laguerre Filter
575 stars

This indicator detects equal highs and lows by comparing prices within user-defined left and right bars using a tolerance percentage. It plots horizontal lines on the price chart for equal highs in one color and lows in another. A screener allows input of mult

Indicator v5 Support & resistanceTrend
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows with Screener
330 stars

This script plots three moving averages on the price chart: a fast EMA or SMA with 10 periods, a slow EMA or SMA with 20 periods, and a trend EMA or SMA with 100 periods. It signals trend changes by drawing a white cross when the fast moving average crosses ab

Indicator v4 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of 3 EMA/SMA + Cross [Alorse]
318 stars

This indicator calculates an ATR trailing stop line derived from the highest high minus an average true range multiple over a specified lookback period. It plots the trailing stop line directly on the price chart and colors price bars based on whether the clos

Indicator v5 TrendVolatility & bands
Updated 2 months ago · MIT GitHub repository of ATR Trailing Stoploss

All Candlestick Patterns

by shunjizhan
292 stars

All Candlestick Patterns detects and highlights a wide range of bullish, bearish, and neutral candlestick patterns directly on the price chart. It features optional trend filtering using either a 50-period simple moving average or a combination of 50-period an

Indicator v4 Candlestick patternsTrend
Updated 3 years ago · None stated GitHub repository of All Candlestick Patterns

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers