Smoothed Gaussian Trend Filter

Parameters: gaussian_length = 15 | poles = 3 (1–4) | smoothing_length = 22 | linreg_offset = 7

Overview

Smoothed Gaussian Trend Filter builds a trend line in layers. It first smooths close prices with a configurable multi-pole Gaussian filter, then runs that result through a linear-regression-style finishing stage to produce the final filter series. An ATR-based supertrend is computed from that finished line instead of raw price.

The indicator returns four synchronized outputs: the finished filter, the derived supertrend line, a directional trend flag, and a ranging flag that flips on when slope direction and supertrend direction disagree. The stream path resets itself when it receives an invalid bar.

Defaults: `gaussian_length = 15`, `poles = 3`, `smoothing_length = 22`, and `linreg_offset = 7`.

Implementation Examples

Run the indicator on candles or on explicit high, low, and close slices.

use vector_ta::indicators::smoothed_gaussian_trend_filter::{
    smoothed_gaussian_trend_filter,
    SmoothedGaussianTrendFilterInput,
    SmoothedGaussianTrendFilterParams,
};
use vector_ta::utilities::data_loader::{Candles, read_candles_from_csv};

let out = smoothed_gaussian_trend_filter(&SmoothedGaussianTrendFilterInput::from_slices(
    &high,
    &low,
    &close,
    SmoothedGaussianTrendFilterParams {
        gaussian_length: Some(15),
        poles: Some(3),
        smoothing_length: Some(22),
        linreg_offset: Some(7),
    },
))?;

let candles: Candles = read_candles_from_csv("data/sample.csv")?;
let candle_out = smoothed_gaussian_trend_filter(
    &SmoothedGaussianTrendFilterInput::with_default_candles(&candles),
)?;

println!("filter = {:?}", out.filter.last());
println!("trend = {:?}", candle_out.trend.last());

API Reference

Input Methods
SmoothedGaussianTrendFilterInput::from_candles(&Candles, SmoothedGaussianTrendFilterParams)
    -> SmoothedGaussianTrendFilterInput

SmoothedGaussianTrendFilterInput::from_slices(&[f64], &[f64], &[f64], SmoothedGaussianTrendFilterParams)
    -> SmoothedGaussianTrendFilterInput

SmoothedGaussianTrendFilterInput::with_default_candles(&Candles)
    -> SmoothedGaussianTrendFilterInput
Parameters Structure
pub struct SmoothedGaussianTrendFilterParams {
    pub gaussian_length: Option<usize>,  // default 15
    pub poles: Option<usize>,            // default 3
    pub smoothing_length: Option<usize>, // default 22
    pub linreg_offset: Option<usize>,    // default 7
}
Output Structure
pub struct SmoothedGaussianTrendFilterOutput {
    pub filter: Vec<f64>,
    pub supertrend: Vec<f64>,
    pub trend: Vec<f64>,
    pub ranging: Vec<f64>,
}
Validation, Warmup & State
  • High, low, and close must all be present, non-empty, and share the same length.
  • A valid bar must satisfy finite inputs and high >= low.
  • gaussian_length and smoothing_length must be positive and no larger than the data length.
  • poles must stay inside the inclusive range 1..=4.
  • The direct path requires at least max(smoothing_length, 21) valid bars after the first valid candle because the supertrend stage uses ATR(21).
  • The stream path returns None until the Gaussian stage, finishing stage, and ATR stage are all ready. Invalid bars reset the internal state.
Builder, Streaming & Batch APIs
SmoothedGaussianTrendFilterBuilder::new()
    .gaussian_length(usize)
    .poles(usize)
    .smoothing_length(usize)
    .linreg_offset(usize)
    .kernel(Kernel)
    .apply(&Candles)
    .apply_slices(&[f64], &[f64], &[f64])
    .into_stream()

SmoothedGaussianTrendFilterStream::try_new(params)
stream.update(high, low, close) -> Option<(f64, f64, f64, f64)>

SmoothedGaussianTrendFilterBatchBuilder::new()
    .gaussian_length_range((start, end, step))
    .poles_range((start, end, step))
    .smoothing_length_range((start, end, step))
    .linreg_offset_range((start, end, step))
    .kernel(Kernel)
    .apply(&Candles)

Python Bindings

Python exposes one scalar function, one stream class, and one batch helper. The scalar path returns four NumPy arrays, the stream emits a four-value tuple or None, and the batch helper returns four reshaped matrices plus the expanded Gaussian, pole, smoothing, and offset axes.

from vector_ta import (
    smoothed_gaussian_trend_filter,
    smoothed_gaussian_trend_filter_batch,
    SmoothedGaussianTrendFilterStream,
)

filter_, supertrend, trend, ranging = smoothed_gaussian_trend_filter(
    high,
    low,
    close,
    gaussian_length=15,
    poles=3,
    smoothing_length=22,
    linreg_offset=7,
)

stream = SmoothedGaussianTrendFilterStream()
point = stream.update(high[-1], low[-1], close[-1])

batch = smoothed_gaussian_trend_filter_batch(
    high,
    low,
    close,
    gaussian_length_range=(10, 20, 5),
    poles_range=(2, 4, 1),
    smoothing_length_range=(18, 30, 6),
    linreg_offset_range=(3, 7, 2),
)

print(batch["rows"], batch["cols"])

JavaScript/WASM Bindings

The WASM layer exposes high-level scalar and batch helpers plus a four-channel host buffer API. The low-level path allocates or fills one contiguous block arranged as filter, supertrend, trend, and ranging slices.

import init, {
  smoothed_gaussian_trend_filter,
  smoothed_gaussian_trend_filter_batch,
  smoothed_gaussian_trend_filter_alloc,
  smoothed_gaussian_trend_filter_free,
  smoothed_gaussian_trend_filter_into,
  smoothed_gaussian_trend_filter_into_host,
} from "vector-ta-wasm";

await init();

const out = smoothed_gaussian_trend_filter(
  high,
  low,
  close,
  15,
  3,
  22,
  7,
);

const batch = smoothed_gaussian_trend_filter_batch(high, low, close, {
  gaussian_length_range: [10, 20, 5],
  poles_range: [2, 4, 1],
  smoothing_length_range: [18, 30, 6],
  linreg_offset_range: [3, 7, 2],
});

CUDA Bindings (Rust)

Additional details for the CUDA bindings can be found inside the VectorTA repository.

Performance Analysis

Comparison:
View:
Placeholder data (no recorded benchmarks for this indicator)

Across sizes, Rust CPU runs about 1.14× faster than Tulip C in this benchmark.

Loading chart...

AMD Ryzen 9 9950X (CPU) | NVIDIA RTX 4090 (GPU)

Related Indicators