STD-Filtered, Gaussian-Kernel-Weighted Moving Average

Aug 29, 2022

Static chart image
Signals
Moving Averages
Volatility

The STD-Filtered, Gaussian-Kernel-Weighted Moving Average indicator provides a non-parametric regression-based smoothing tool that utilizes a Gaussian kernel function and standard deviation filtering to minimize price noise while maintaining trend responsiveness.

Usage

The Usage section describes how the script can be used, particularly in identifying trends and potential reversal points through smoothed price action.

  • Trend Identification: The indicator colors the moving average line and price bars based on the current trend. A green line indicates a bullish trend, while a red line indicates a bearish trend.
  • Signal Generation: The tool provides "L" (Long) and "S" (Short) labels when the Gaussian-weighted output crosses its previous value. Users should ensure the current bar closes before acting on a signal to avoid issues with intraday fluctuations.
  • Source Selection: The indicator supports a wide range of source types, including standard price inputs, Heikin-Ashi variations, and smoothed "Better Heikin-Ashi" (HAB) inputs.
  • Filter Application: Users can choose to apply a standard deviation filter to the raw price source, the final output signal, or both. This helps in "stepping" the moving average, keeping the value static until price movement exceeds a specific volatility threshold.

Details

The Gaussian-Kernel-Weighted Moving Average (GKWMA) is built on the concept of Kernel estimation. Unlike standard regression models that may repaint by predicting past values based on future data, this implementation calculates the weighted function at each bar to predict the current value, making it suitable for real-time trading.

The Gaussian kernel function is defined as: K(u) = (1 / sqrt(2pi)) * e^(-0.5 * (j / bw)^2)

Where:

  • j represents the distance from the current point.
  • bw (Bandwidth) acts as the smoothing parameter. A higher bandwidth increases the smoothing effect but may introduce more lag.

The indicator also incorporates a volatility-based filter. It calculates the standard deviation over a user-defined period and only updates the price or signal value if the change from the previous bar exceeds the product of the standard deviation and the "Filter Deviations" multiplier.

Settings

Source Settings

  • Heiken-Ashi Better Smoothing: Selects the smoothing method (AMA, T3, or Kaufman) for HAB source types.
  • Source: Determines the input price data, ranging from standard Close to complex Trend Biased and Heikin-Ashi derivatives.

Gaussian-Kernel Settings

  • Bandwidth: Controls the width of the Gaussian distribution. Higher values result in a smoother, slower-moving average.

Filter Settings

  • Filter Options: Choose whether to apply the standard deviation filter to the input "Price", the "GKS Filter" (output), or "Both".
  • Filter Deviations: The multiplier for the standard deviation. Higher values create a more "stepped" or stagnant line that only moves during significant volatility.
  • Filter Period: The lookback period used to calculate the standard deviation for the filter.

UI Options

  • Color bars?: Enables or disables the coloring of price bars based on trend direction.
  • Show signals?: Toggles the visibility of the Long and Short plot shapes.

Moving Average Inputs

  • Kaufman's / AMA Settings: These parameters control the internal calculations if Kaufman or Adaptive Moving Average smoothing is selected in the Source Settings.

FAQ

How do I adjust the lag of the moving average? The lag is primarily controlled by the Bandwidth setting. Lowering the bandwidth makes the indicator more responsive to recent price changes, while increasing it provides a smoother, more lagged trend line.

What does the Standard Deviation filter do? The filter prevents the moving average from changing value unless the price move is significant relative to recent volatility. This is useful for avoiding "whipsaws" during sideways or low-volatility markets.

How can I access this indicator? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free access on the following platforms
tradingviewSymbolTradingView
ninjatraderNinjaTrader
metatrader4MetaTrader 4/5
thinkorswimThinkorswim

Unlock Unlimited Access to the LuxAlgo Library

Upgrade your plan to get all indicators, strategies, charts, and full access to Quant, our AI agent.

Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.

Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.

As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.

Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.

Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.

This does not represent our full Disclaimer. Please read our full disclaimer.

© 2026 LuxAlgo Global, LLC.