Files
QuanTAlib/lib/cycles/ssfdsp/Ssfdsp.md
T
Miha Kralj 3dd05f23e4 Refactor indicators to include "Ehlers" in names and descriptions for clarity
- Updated the name and description of the Hilbert Trendline (HTIT) to "Ehlers Hilbert Transform Instantaneous Trend (HTIT)".
- Changed the name and description of the MESA Adaptive Moving Average (MAMA) to "Ehlers MESA Adaptive Moving Average".
- Modified the Center of Gravity (CG) indicator to "Ehlers Center of Gravity (CG)".
- Renamed the Detrended Synthetic Price (DSP) to "Ehlers Detrended Synthetic Price (DSP)".
- Updated the Autocorrelation Periodogram (EACP) to "Ehlers Autocorrelation Periodogram (EACP)".
- Changed the Homodyne Discriminator (HOMOD) to "Ehlers Homodyne Discriminator (HOMOD)".
- Updated the Hilbert Transform Dominant Cycle Period and Phase indicators to include "Ehlers" in their names.
- Renamed the Hilbert Transform Phasor Components to "Ehlers Hilbert Transform Phasor Components (HT_PHASOR)".
- Updated the SineWave indicator to "Ehlers Hilbert Transform SineWave (HT_SINE)".
- Changed the Phasor Analysis indicator to "Ehlers Hilbert Transform Phasor Components (HT_PHASOR)".
- Updated the SSF-Based Detrended Synthetic Price to "Ehlers SSF Detrended Synthetic Price (SSFDSP)".
- Renamed the Ultimate Channel to "Ehlers Ultimate Channel (UCHANNEL)".
- Added new indicators: Moving Average Variable Period (MAVP), Ehlers Predictive Moving Average (PMA), Ehlers Reverse EMA (REVERSEEMA), and Ehlers Trendflex Indicator (TRENDFLEX).
- Updated various SVG badges to reflect changes in classes, comments, source files, lines of code, methods, and public types.
2026-02-18 19:08:15 -08:00

150 lines
4.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# SSFDSP: Ehlers SSF Detrended Synthetic Price
> "The Super-Smoother filter provides Butterworth-quality noise rejection—combine two of them and you isolate cycles with surgical precision."
The SSF-Based Detrended Synthetic Price (SSFDSP) is an advanced oscillator by John Ehlers. It creates a synthetic, detrended price series by subtracting a half-cycle Super-Smoother from a quarter-cycle Super-Smoother, providing superior noise rejection and reduced lag compared to EMA-based DSP.
## Historical Context
Ehlers introduced the concept of "Synthetic Price" to remove the DC (trend) component from market data, isolating cyclic energy. While earlier versions used EMAs, the SSF variant exploits the 2-pole Butterworth characteristics of the Super-Smoother Filter to achieve cleaner separation between trend and cycle.
The SSF provides zero phase lag at the cutoff frequency, making it ideal for cycle isolation in noisy market data.
## Architecture & Physics
The indicator computes the difference between two Super-Smoother filters tuned to fractions of the dominant cycle period.
### 1. Filter Periods
$$
P_{fast} = \max(2, \text{round}(P / 4))
$$
$$
P_{slow} = \max(3, \text{round}(P / 2))
$$
### 2. Super-Smoother Coefficients
$$
\alpha = \frac{\pi\sqrt{2}}{period}
$$
$$
c_2 = 2e^{-\alpha}\cos(\alpha)
$$
$$
c_3 = -e^{-2\alpha}
$$
$$
c_1 = 1 - c_2 - c_3
$$
### 3. SSF Recursion
$$
SSF_t = c_1 \cdot \frac{P_t + P_{t-1}}{2} + c_2 \cdot SSF_{t-1} + c_3 \cdot SSF_{t-2}
$$
### 4. SSFDSP Output
$$
SSFDSP = SSF_{fast} - SSF_{slow}
$$
## Performance Profile
### Operation Count (Streaming Mode, per Bar)
| Operation | Count | Cost (cycles) | Subtotal |
| :--- | :---: | :---: | :---: |
| FMA (SSF updates) | 4 | 4 | 16 |
| MUL (coefficients) | 2 | 3 | 6 |
| ADD/SUB (input avg, output) | 3 | 1 | 3 |
| **Total** | **9** | — | **~25 cycles** |
### Complexity Analysis
- **Streaming:** O(1) per bar—fixed 2-pole IIR filters
- **Memory:** O(1)—only filter state variables
- **Warmup:** ~2 × slow period for convergence
- **Note:** Recursive dependencies prevent SIMD vectorization
## Validation
| Library | Status | Notes |
| :--- | :---: | :--- |
| TA-Lib | N/A | Not standard |
| Skender | N/A | Not standard |
| PineScript | ✅ | Matches Ehlers' reference logic |
## Usage & Pitfalls
- **Oscillates around zero**—positive values indicate bullish cycle phase
- **Zero crossings** signal cycle phase changes—entry points in direction of cross
- **Period mismatch** degrades amplitude and phase accuracy
- **Smoother than EMA-DSP** with sharper turning points
- **Divergence** (price highs vs DSP highs) indicates trend exhaustion
- **Pre-smooth input** for extremely noisy data
## API
```mermaid
classDiagram
class Ssfdsp {
+int Period
+double Value
+bool IsHot
+Ssfdsp(int period)
+Ssfdsp(ITValuePublisher source, int period)
+TValue Update(TValue input, bool isNew)
+void Reset()
}
```
### Class: `Ssfdsp`
| Parameter | Type | Default | Range | Description |
| :--- | :--- | :--- | :--- | :--- |
| `period` | `int` | `40` | `≥4` | Expected dominant cycle period |
### Properties
- `Value` (`double`): The current SSFDSP value (oscillates around 0)
- `IsHot` (`bool`): Returns `true` when warmup is complete
### Methods
- `Update(TValue input, bool isNew)`: Updates the indicator with a new data point
## C# Example
```csharp
using QuanTAlib;
// Initialize with a 40-bar dominant cycle assumption
var ssfdsp = new Ssfdsp(period: 40);
// Update with streaming data
foreach (var bar in quotes)
{
var result = ssfdsp.Update(new TValue(bar.Date, bar.Close));
if (ssfdsp.IsHot)
{
Console.WriteLine($"{bar.Date}: SSF-DSP = {result.Value:F4}");
// Zero crossing detection
if (result.Value > 0 && ssfdsp.Previous.Value <= 0)
Console.WriteLine(" → Bullish cycle phase");
else if (result.Value < 0 && ssfdsp.Previous.Value >= 0)
Console.WriteLine(" → Bearish cycle phase");
}
}
// Batch calculation
var output = Ssfdsp.Calculate(sourceSeries, period: 40);
```