mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-17 10:08:05 +00:00
feat(dynamics): add PlusDI, MinusDI, PlusDM, MinusDM indicators
Complete thin Dx-composition wrapper indicators with full test coverage: - PlusDi/MinusDi: Directional Indicator wrappers (DiPlus/DiMinus from Dx) - PlusDm/MinusDm: Directional Movement wrappers (DmPlus/DmMinus from Dx) - Individual validation tests per indicator directory (TALib, Skender, bounds) - Combined unit tests (DiDm.Tests.cs) and validation tests (DiDm.Validation.Tests.cs) - Quantower wrappers + tests for all 4 indicators - PineScript v6 implementations with compensated RMA - Normalized .md documentation for all indicators and categories - 182 tests passing, 0 failures
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
# Filters
|
||||
|
||||
> "All moving averages are low-pass filters. The question is which trade-offs you accept." John Ehlers
|
||||
|
||||
Signal processing filters adapted for financial time series. These are not indicators in the traditional sense: they are building blocks. Low-pass removes noise. High-pass isolates cycles. Band-pass extracts specific frequencies. Each filter type trades off smoothness, lag, and overshoot differently.
|
||||
|
||||
## Indicators
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# AGC: Ehlers Automatic Gain Control
|
||||
|
||||
> *The purpose of the AGC is to normalize the amplitude of any indicator to unity.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -16,8 +18,6 @@
|
||||
- Requires `1` bar of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The purpose of the AGC is to normalize the amplitude of any indicator to unity." — John F. Ehlers, TASC January 2015
|
||||
|
||||
## Introduction
|
||||
|
||||
The Automatic Gain Control normalizes any oscillating signal to the \[-1, +1\] range through exponential peak tracking. Unlike fixed-window normalization (min-max scaling), AGC adapts continuously: the peak decays exponentially each bar and ratchets up instantly when the signal exceeds the current peak. The result is amplitude-independent comparison of filter outputs across instruments and timeframes. Ehlers introduced AGC as the final stage of his "Universal Oscillator" — a signal-processing chain that converts any price series into a bounded, zero-mean indicator suitable for threshold-based trading signals.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# ALAGUERRE: Ehlers Adaptive Laguerre Filter
|
||||
|
||||
> *The best filter is one that knows when to listen closely and when to smooth aggressively.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires `max(4, length)` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The best filter is one that knows when to listen closely and when to smooth aggressively." -- John F. Ehlers (paraphrased)
|
||||
|
||||
## Introduction
|
||||
|
||||
The Adaptive Laguerre Filter extends Ehlers' four-element all-pass cascade by replacing the fixed damping factor with a per-bar adaptive alpha derived from tracking-error normalization. When price diverges from the filter output (trending conditions), alpha increases toward 1 for faster tracking. When price stays near the filter output (ranging conditions), alpha decreases toward 0 for heavier smoothing. The adaptation mechanism uses a highest/lowest normalization of the absolute tracking error over a lookback window, followed by median smoothing to prevent whipsaw in the coefficient.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# BK: Baxter-King Band-Pass Filter
|
||||
|
||||
> *The business cycle is whatever remains after you strip away the trend and the noise. Baxter and King figured out the stripping.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -16,8 +18,6 @@
|
||||
- Requires `2K+1` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The business cycle is whatever remains after you strip away the trend and the noise. Baxter and King figured out the stripping."
|
||||
|
||||
The **Baxter-King Band-Pass Filter** is a symmetric finite impulse response (FIR) filter that approximates the ideal spectral band-pass by truncating the infinite sinc-like impulse response at lag $K$ and normalizing the weights to sum to zero. It extracts cyclical components with periodicities between $p_L$ (low) and $p_H$ (high) bars, rejecting both the DC trend and high-frequency noise. Output oscillates around zero with a fixed delay of $K$ bars.
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# BESSEL: Bessel Filter
|
||||
|
||||
> *The Bessel filter preserves the shape of the input signal — maximum flatness in the time domain at the cost of a gentler rolloff.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Bilateral Filter
|
||||
|
||||
> *Smoothing without blurring edges? It's not magic, it's just math.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Smoothing without blurring edges? It's not magic, it's just math."
|
||||
|
||||
The Bilateral Filter is a non-linear, edge-preserving, and noise-reducing smoothing filter. Unlike standard Gaussian filters that blur everything indiscriminately, the Bilateral Filter respects strong edges by weighting pixels based on both their spatial distance and their intensity difference (range).
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# BPF (Bandpass Filter)
|
||||
|
||||
> *Most market data is noise. A sliver is signal. The rest is just detailed evidence of human panic.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -16,8 +18,6 @@
|
||||
- Requires `Math.Max(lowerPeriod, upperPeriod)` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Most market data is noise. A sliver is signal. The rest is just detailed evidence of human panic."
|
||||
|
||||
The **BPF** (BandPass Filter) is a second-order IIR architecture designed to surgically excise specific frequency components from a time series. By cascading a HighPass Filter (to reject trend) and a LowPass Filter (to reject noise), it isolates cyclic energy within a user-defined window. Unlike simple moving average crossovers which smear data, the BPF relies on Gaussian-based coefficients to achieve steeper roll-off with deterministic phase characteristics.
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# BUTTER2: Ehlers 2-Pole Butterworth Filter
|
||||
|
||||
> *Maximally flat frequency response in the passband.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires `4 * period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Maximally flat frequency response in the passband."
|
||||
|
||||
The 2-Pole Butterworth Filter (BUTTER2) is a signal processing tool designed to provide maximally flat frequency response in the passband. Developed by British engineer Stephen Butterworth in 1930, it offers traders a means to smooth price data without introducing ripples in the frequency response. This implementation provides a 2nd-order low-pass filter that effectively removes high-frequency market noise while preserving lower-frequency trend components. Compared to other filters, Butterworth offers an optimal compromise between smoothing efficiency and signal fidelity, making it a versatile choice for various market conditions.
|
||||
|
||||
## Core Concepts
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# BUTTER3: Ehlers 3-Pole Butterworth Filter
|
||||
|
||||
> *Steeper rolloff demands a third pole.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires `6 * period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Steeper rolloff demands a third pole."
|
||||
|
||||
The 3-Pole Butterworth Filter (BUTTER3) extends the classic Butterworth design to third order, providing -60 dB/decade rolloff compared to -40 dB/decade for the 2-pole variant. Developed from John Ehlers' formulation in "Cybernetic Analysis for Stocks and Futures" (2004), this implementation uses the same pole placement as the 3-pole Super Smoother (SSF3) but with binomial (1,3,3,1) feedforward weights that preserve the maximally flat passband characteristic. The steeper rolloff makes BUTTER3 more effective at rejecting high-frequency noise, at the cost of slightly more lag than BUTTER2.
|
||||
|
||||
## Core Concepts
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# CFITZ: Christiano-Fitzgerald Band-Pass Filter
|
||||
|
||||
> *Christiano-Fitzgerald isolates a frequency band from the time series, extracting cycles of a chosen wavelength range.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# CHEBY1: Chebyshev Type I Lowpass Filter
|
||||
|
||||
> *Chebyshev Type I trades passband ripple for a steeper rolloff — sharper frequency separation at the cost of amplitude wobble.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# CHEBY2 (Chebyshev Type II / Inverse Chebyshev)
|
||||
|
||||
> *Chebyshev Type II pushes the ripple into the stopband, keeping the passband flat while still achieving a steep transition.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# EDCF: Ehlers Distance Coefficient Filter
|
||||
|
||||
> *Ehlers' distance coefficient filter adjusts smoothing based on how far price has traveled, blending trend-following with noise rejection.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# ELLIPTIC: 2nd Order Elliptic Lowpass Filter
|
||||
|
||||
> *If you want a vertical cliff, you have to accept a few bumps on the plateau.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "If you want a vertical cliff, you have to accept a few bumps on the plateau."
|
||||
|
||||
The Elliptic filter (or Cauer filter for the history buffs) is the uncompromising extremist of linear filtering. It offers the steepest possible roll-off for a given order, but extracts a heavy price: ripple in both the passband and the stopband. While Butterworth is polite and Chebyshev is opinionated, Elliptic is aggressive. This implementation delivers a sharp 2nd-order Lowpass response with **1dB passband ripple** and a crushing **40dB stopband attenuation**.
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Gauss: Gaussian Filter
|
||||
|
||||
> *SMA smears data like cheap paint. Gaussian filtering respects the signal's soul.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -18,8 +20,6 @@
|
||||
- Requires `2⌈3σ⌉+1` bars of warmup before first valid output (IsHot = true). Default: **7 bars** (σ=1.0).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "SMA smears data like cheap paint. Gaussian filtering respects the signal's soul."
|
||||
|
||||
Gauss (Gaussian Filter) is a smoothing filter that applies a Gaussian kernel to time series data. Unlike Simple Moving Average (SMA), which weights all points in the window equally (boxcar function), the Gaussian filter applies weights that follow a bell curve distribution. This minimizes lag while providing superior noise reduction and significantly better preservation of signal edges.
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Hann: Hann FIR Filter
|
||||
|
||||
> *The Hanning window whispers where the Boxcar screams. Smoothness is not just an aesthetic; it's a mathematical necessity.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires `length` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The Hanning window whispers where the Boxcar screams. Smoothness is not just an aesthetic; it's a mathematical necessity."
|
||||
|
||||
Hann (Hann Filter) is a Finite Impulse Response (FIR) smoothing filter that applies a Hann window to time series data. Named after Julius von Hann, this filter uses a cosine-sum window function that tapers inputs to zero at the edges. This tapering process significantly reduces spectral leakage and provides excellent high-frequency noise attenuation compared to a Simple Moving Average (SMA).
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# HP - Hodrick-Prescott Filter
|
||||
|
||||
> *Trends are not lines; they are curves that we simplify for our sanity, often at the cost of reality.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -18,8 +20,6 @@
|
||||
- Requires `⌈2√λ⌉` bars of warmup before first valid output (IsHot = true). Default: **~80 bars** (λ=1600).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Trends are not lines; they are curves that we simplify for our sanity, often at the cost of reality."
|
||||
|
||||
The Hodrick-Prescott (HP) filter is a widely used tool in macroeconomics for separating the cyclical component of a time series from raw data. While the standard HP filter is non-causal (requiring future data), this implementation uses a causal approximation suitable for real-time streaming analysis.
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# HPF: Ehlers Highpass Filter
|
||||
|
||||
> *Noise is just signal you haven't figured out how to filter yet. Or maybe, it's the only signal that matters.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -16,8 +18,6 @@
|
||||
- Requires `length` bars of warmup before first valid output (IsHot = true). Default: **40 bars**.
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Noise is just signal you haven't figured out how to filter yet. Or maybe, it's the only signal that matters."
|
||||
|
||||
The 2-Pole Highpass Filter (HPF) is designed to separate high-frequency components (like cycles and noise) from the underlying trend. By suppressing low-frequency movements, it acts as a "detrender," making it invaluable for oscillator construction and cycle analysis.
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Kalman Filter (KALMAN)
|
||||
|
||||
> *Prediction is very difficult, especially if it's about the future.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -18,8 +20,6 @@
|
||||
- Requires `10` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Prediction is very difficult, especially if it's about the future." — Niels Bohr. The Kalman Filter doesn't just predict; it optimally estimates the present by balancing what it thinks should happen with what actually happened.
|
||||
|
||||
The **Kalman Filter** is a recursive algorithm that estimates the state of a dynamic system from a series of incomplete and noisy measurements. In technical analysis, it acts as a sophisticated smoothing filter that adapts to price changes based on specified noise covariances. Unlike simple moving averages that treat all past data equally or with fixed weights, the Kalman Filter dynamically adjusts its "trust" between its own prediction and the new price data.
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# LAGUERRE: Ehlers Laguerre Filter
|
||||
|
||||
> *The problem with conventional filters is that they use unit delays. All-pass filters replace unit delays with frequency-dependent delays, and that changes everything.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -18,8 +20,6 @@
|
||||
- Requires `WarmupBars` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The problem with conventional filters is that they use unit delays. All-pass filters replace unit delays with frequency-dependent delays, and that changes everything." — John F. Ehlers
|
||||
|
||||
## Introduction
|
||||
|
||||
The Laguerre Filter is a four-element IIR (Infinite Impulse Response) filter designed by John F. Ehlers that uses cascaded all-pass sections controlled by a single damping factor γ (gamma). It produces remarkably smooth output from only four data elements. When γ = 0, the filter degenerates to a 4-tap FIR (triangular weighted average). As γ approaches 1, smoothing increases with correspondingly greater lag. The filter achieves smoothing quality comparable to much longer conventional moving averages while maintaining a fixed 4-element structure.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# LMS: Least Mean Squares Adaptive Filter
|
||||
|
||||
> *The filter that learns from its mistakes, one gradient step at a time.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -16,8 +18,6 @@
|
||||
- Requires `order + 1` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The filter that learns from its mistakes, one gradient step at a time."
|
||||
|
||||
The **Least Mean Squares (LMS) Adaptive Filter** is the Widrow-Hoff adaptive FIR filter, the simplest and most widely deployed adaptive algorithm in signal processing. It maintains an `order`-tap weight vector that learns to predict the current input from its recent history, updating weights via the Normalized LMS (NLMS) gradient descent rule. The result is a price-following overlay filter that automatically adapts its frequency response to changing market conditions with O(order) per-bar complexity.
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Loess: Locally Estimated Scatterplot Smoothing
|
||||
|
||||
> *When global models fail, act locally. LOESS fits the data by ignoring the noise and embracing the neighborhood.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires `Period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "When global models fail, act locally. LOESS fits the data by ignoring the noise and embracing the neighborhood."
|
||||
|
||||
Locally Estimated Scatterplot Smoothing (LOESS) applies a weighted linear regression over a localized window of nearest neighbors. Unlike simple averaging or global linear regression, LOESS estimates the deterministic trend point-by-point, giving maximum influence to recent data and decaying elegantly at the edges.
|
||||
|
||||
## Historical Context / The Standard
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# MODF: Modular Filter
|
||||
|
||||
> *alexgrover designed a filter with two paths — one tracks uptrends, one tracks downtrends — and a state machine that picks between them. Add a beta knob for aggression and an optional feedback loop, and you get one of the most versatile adaptive filters on TradingView.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "alexgrover designed a filter with two paths — one tracks uptrends, one tracks downtrends — and a state machine that picks between them. Add a beta knob for aggression and an optional feedback loop, and you get one of the most versatile adaptive filters on TradingView."
|
||||
|
||||
MODF is a dual-path adaptive filter that maintains separate upper and lower EMA bands with conditional state selection. The upper band snaps up to price when price exceeds it (tracking rallies), while the lower band snaps down when price drops below it (tracking selloffs). An oscillator state variable determines which band is active, and a beta parameter controls the blend between filter mode (smooth tracking) and trailing-stop mode (step-like following). An optional feedback loop blends the filter's output back into its input for additional smoothing. Developed by alexgrover (CPO at LuxAlgo).
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Notch Filter
|
||||
|
||||
> *A notch filter surgically removes a single frequency, silencing one resonance while leaving the rest of the spectrum untouched.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# NW: Nadaraya-Watson Kernel Regression
|
||||
|
||||
> *Nadaraya and Watson independently discovered the same thing in 1964: weight each observation by how close it is, normalize, and average. Fifty years later, it became one of the most popular nonparametric smoothers on TradingView. The math did not change; only our ability to compute it in real time.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Nadaraya and Watson independently discovered the same thing in 1964: weight each observation by how close it is, normalize, and average. Fifty years later, it became one of the most popular nonparametric smoothers on TradingView. The math did not change; only our ability to compute it in real time."
|
||||
|
||||
NW computes the Nadaraya-Watson kernel regression estimator with a Gaussian kernel, producing a nonparametric smooth of the price series. For each bar, every observation in the lookback window is weighted by a Gaussian function of its temporal distance, with the bandwidth parameter $h$ controlling the effective smoothing radius. Small $h$ tracks price tightly (low bias, high variance); large $h$ smooths heavily (high bias, low variance). This implementation is non-repainting (backward-looking only).
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# OneEuro — One Euro Filter
|
||||
|
||||
> *The One Euro filter adapts its cutoff frequency to signal speed — slow movements get heavy smoothing, fast ones pass through.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# RLS: Recursive Least Squares Adaptive Filter
|
||||
|
||||
> *The man who has no patience has no wisdom.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -18,8 +20,6 @@
|
||||
- Requires `order + 1` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The man who has no patience has no wisdom." — but waiting is not the same as convergence. RLS converges where LMS merely approaches.
|
||||
|
||||
## Introduction
|
||||
|
||||
The Recursive Least Squares (RLS) adaptive filter is the Rolls-Royce of adaptive FIR filters. Where LMS crawls toward the Wiener solution one gradient step at a time, RLS arrives in approximately *order* iterations by maintaining an inverse correlation matrix $P$ that captures the full second-order statistics of the input signal. The trade-off is computational: $O(n^2)$ per bar versus LMS's $O(n)$, where $n$ is the filter order. For orders below 64, the convergence advantage typically outweighs the cost.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# RMED: Ehlers Recursive Median Filter
|
||||
|
||||
> *John Ehlers combined two tools that rarely meet: the median (nonlinear, spike-resistant) and the EMA (smooth, recursive). The median kills the spikes, the EMA smooths the survivors. Together they produce a filter that is both resistant and smooth.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires **5 bars** of warmup (MedianWindow) before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "John Ehlers combined two tools that rarely meet: the median (nonlinear, spike-resistant) and the EMA (smooth, recursive). The median kills the spikes, the EMA smooths the survivors. Together they produce a filter that is both resistant and smooth."
|
||||
|
||||
RMED applies exponential smoothing to a 5-bar running median, creating a nonlinear IIR filter that rejects impulsive spike noise while providing smooth recursive tracking. The median component eliminates outliers that would corrupt any linear filter, while the EMA provides the recursive continuity that a pure median lacks. The EMA constant $\alpha$ is derived from Ehlers' cycle-period formula, connecting the smoothing rate to the dominant cycle length of the data.
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# ROOFING: Ehlers Roofing Filter
|
||||
|
||||
> *The trend is your friend until it overwhelms the signal. The noise is your enemy until you mistake it for alpha.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -16,8 +18,6 @@
|
||||
- Requires `hpLength` bars of warmup before first valid output (IsHot = true). Default: **48 bars**.
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The trend is your friend until it overwhelms the signal. The noise is your enemy until you mistake it for alpha."
|
||||
|
||||
The **Roofing Filter** is John Ehlers' bandpass architecture designed specifically for oscillator construction. It cascades a 2nd-order Butterworth Highpass (to strip trend) with a Super Smoother Lowpass (to strip noise), passing only the cyclic energy within a user-defined frequency band. The output oscillates around zero, with zero crossings serving as directional signals.
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# SAK: Swiss Army Knife
|
||||
|
||||
> "Nine filters walk into a bar. The bartender says, 'What'll it be?' They answer in unison: 'Same equation, different coefficients.'"
|
||||
> *Nine filters walk into a bar. The bartender says, 'What'll it be?' They answer in unison: 'Same equation, different coefficients.'*
|
||||
|
||||
SAK is John Ehlers' unified second-order IIR filter framework that collapses nine distinct filter types into a single difference equation. Change five coefficients and the same code path produces EMA, SMA, Gaussian, Butterworth, FIR smoother, high-pass, two-pole high-pass, band-pass, or band-stop output. One transfer function. Nine behaviors. Zero code duplication.
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# SGF: Savitzky-Golay Filter
|
||||
|
||||
> *SMA smoothes. Savitzky-Golay understands.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "SMA smoothes. Savitzky-Golay understands."
|
||||
|
||||
SGF (Savitzky-Golay Filter) is a digital signal processing technique that smoothes data by fitting successive sub-sets of adjacent data points with a low-degree polynomial by the method of linear least squares. Unlike standard moving averages that simply average the points, SGF preserves higher moments of the data distribution, such as the area, center of gravity, and line width. This makes it exceptionally good at preserving features of the distribution such as relative maxima and minima and width, which are usually flattened by other smoothing techniques.
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# SPBF: Ehlers Super Passband Filter
|
||||
|
||||
> *Two EMAs walk into a frequency domain. The difference between them is the only thing worth trading.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -16,8 +18,6 @@
|
||||
- Requires `max(longPeriod, rmsPeriod)` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Two EMAs walk into a frequency domain. The difference between them is the only thing worth trading."
|
||||
|
||||
The **Super Passband Filter** is John Ehlers' wide-band bandpass constructed by differencing two z-transformed EMAs with Ehlers-style smoothing ($\alpha = 5/N$). It rejects both DC trend and high-frequency noise, passing only the cyclic energy between two EMA-defined cutoff frequencies. The output oscillates around zero, with an RMS trigger envelope providing signal/noise discrimination.
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# SSF2: Ehlers 2-Pole Super Smoother Filter
|
||||
|
||||
> *Noise is the enemy of the trend follower. The Super Smooth Filter is the silencer.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Noise is the enemy of the trend follower. The Super Smooth Filter is the silencer."
|
||||
|
||||
The 2-Pole Super Smooth Filter (SSF2) is a 2-pole Butterworth filter designed by John Ehlers. It offers superior noise reduction compared to standard moving averages while maintaining minimal lag. By using complex conjugate poles, it achieves a "maximally flat" response in the passband, meaning it preserves the trend signal with high fidelity while aggressively suppressing high-frequency noise.
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# SSF3: Ehlers 3-Pole Super Smoother Filter
|
||||
|
||||
> *Three poles, one sample. Maximum smoothing, minimum ceremony.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires `6 * period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Three poles, one sample. Maximum smoothing, minimum ceremony."
|
||||
|
||||
The 3-Pole Super Smoother Filter (SSF3) extends Ehlers' Super Smoother concept to third order, providing -60 dB/decade rolloff compared to -40 dB/decade for the 2-pole variant (SSF2). It shares identical pole placement with BUTTER3 but uses a single-sample feedforward (`coef1 * x`) instead of the binomial-weighted 4-sample average (`coef1 * (x + 3x1 + 3x2 + x3)`). This makes SSF3 more responsive to recent price changes while still delivering aggressive high-frequency noise suppression.
|
||||
|
||||
## Core Concepts
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# USF: Ehlers Ultimate Smoother Filter
|
||||
|
||||
> *The Ultimate Smoother achieves superior smoothing by subtracting high-frequency components using a high-pass filter, resulting in zero lag in the passband.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The Ultimate Smoother achieves superior smoothing by subtracting high-frequency components using a high-pass filter, resulting in zero lag in the passband."
|
||||
|
||||
The Ultimate Smoother Filter (USF) is a zero-lag smoothing filter introduced by John Ehlers in the April 2024 issue of *Technical Analysis of Stocks & Commodities*. It builds upon the Super Smoother Filter (SSF) by using a high-pass filter to remove high-frequency noise, leaving a smooth low-frequency component with minimal lag.
|
||||
|
||||
## Historical Context
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# VOSS: Ehlers Voss Predictive Filter
|
||||
|
||||
> *The best filter is one that tells you what is about to happen, not what already did.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -16,8 +18,6 @@
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The best filter is one that tells you what is about to happen, not what already did." — paraphrasing Ehlers
|
||||
|
||||
## Introduction
|
||||
|
||||
The Voss Predictive Filter is a two-stage signal processing pipeline that extracts a dominant cycle from noisy price data and then predicts its future trajectory using negative group delay. Stage 1 is a two-pole bandpass filter (BPF) that isolates cycles near a specified period. Stage 2 is the Voss predictor, which applies a weighted feedback summation over past output values to shift the filter response forward in time. The result is a leading oscillator that anticipates bandpass zero crossings by a configurable number of bars. Crossings between the Filt (bandpass) and Voss (predictor) lines generate early trade signals with reduced lag.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# WAVELET: Denoising Wavelet Filter
|
||||
|
||||
> *The wavelet transform is to the Fourier transform what a microscope is to a telescope: same math, different scale.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -18,8 +20,6 @@
|
||||
- Requires `2^levels` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The wavelet transform is to the Fourier transform what a microscope is to a telescope: same math, different scale."
|
||||
|
||||
## Introduction
|
||||
|
||||
The Wavelet Denoising Filter applies an *à trous* (with holes) Haar wavelet decomposition with soft thresholding to remove high-frequency noise from price series while preserving trend structure and edges. Unlike classical low-pass filters that blur everything uniformly, wavelet denoising estimates the noise floor at each decomposition level via Median Absolute Deviation (MAD) and surgically removes only coefficients below the threshold. The result: noise reduction without the phase lag or overshoot penalty of IIR alternatives.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Wiener Filter
|
||||
|
||||
> *The signal is the truth. The noise is just an opinion.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Filter |
|
||||
@@ -17,8 +19,6 @@
|
||||
- Requires `Math.Max(period, smoothPeriod)` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The signal is the truth. The noise is just an opinion."
|
||||
|
||||
The Wiener Filter is an optimal linear filter that attempts to minimize the mean square error between the estimated random process and the desired process. In the context of technical analysis, it acts as an adaptive smoothing filter that adjusts its responsiveness based on the local statistical properties of the data (signal-to-noise ratio). When the signal variance is high relative to noise variance, the filter follows the input closely. When noise dominates, it smooths aggressively.
|
||||
|
||||
## Historical Context
|
||||
|
||||
Reference in New Issue
Block a user