mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-21 12:08:05 +00:00
87 lines
3.2 KiB
Markdown
87 lines
3.2 KiB
Markdown
# DECO: Ehlers Decycler Oscillator
|
||||
|
|
|
|||
|
|
## Overview
|
|||
|
|
|
|||
|
|
The Decycler Oscillator (DECO) is a DSP-based oscillator developed by John F. Ehlers that isolates intermediate-frequency market cycles. It computes the difference between two 2-pole Butterworth high-pass filters with different cutoff periods, revealing the spectral band between the two cutoff frequencies.
|
|||
|
|
|
|||
|
|
## Origin
|
|||
|
|
|
|||
|
|
- **Author:** John F. Ehlers
|
|||
|
|
- **Source:** "Decyclers", Technical Analysis of Stocks & Commodities, September 2015
|
|||
|
|
- **Category:** Oscillator / Digital Signal Processing
|
|||
|
|
|
|||
|
|
## Formula
|
|||
|
|
|
|||
|
|
The DECO uses two 2-pole Butterworth high-pass filters:
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
α = (cos(0.707 × 2π/period) + sin(0.707 × 2π/period) - 1) / cos(0.707 × 2π/period)
|
|||
|
|
HP[n] = (1 - α/2)² × (x[n] - 2×x[n-1] + x[n-2]) + 2×(1-α) × HP[n-1] - (1-α)² × HP[n-2]
|
|||
|
|
|
|||
|
|
DECO = HP_long - HP_short
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
The 0.707 factor (1/√2) places the filter response at the -3 dB Butterworth design point.
|
|||
|
|
|
|||
|
|
### Transfer Function
|
|||
|
|
|
|||
|
|
Each HP filter has the z-domain transfer function:
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
H(z) = (1-α/2)² × (1 - 2z⁻¹ + z⁻²) / (1 - 2(1-α)z⁻¹ + (1-α)²z⁻²)
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
The DECO output is the difference H_long(z) - H_short(z), which forms a bandpass response isolating cycles between the short and long cutoff periods.
|
|||
|
|
|
|||
|
|
## Parameters
|
|||
|
|
|
|||
|
|
| Parameter | Type | Default | Range | Description |
|
|||
|
|
|-----------|------|---------|-------|-------------|
|
|||
|
|
| shortPeriod | int | 30 | > 0 | Short HP cutoff period (bars) |
|
|||
|
|
| longPeriod | int | 60 | > shortPeriod | Long HP cutoff period (bars) |
|
|||
|
|
|
|||
|
|
## Interpretation
|
|||
|
|
|
|||
|
|
The Decycler Oscillator provides several analytical perspectives:
|
|||
|
|
|
|||
|
|
- **Zero-Line Crossovers:**
|
|||
|
|
- Crossing above zero indicates bullish cycle momentum
|
|||
|
|
- Crossing below zero indicates bearish cycle momentum
|
|||
|
|
- The zero-crossing timing is relatively lag-free
|
|||
|
|
|
|||
|
|
- **Band Isolation:**
|
|||
|
|
- The oscillator extracts only cycles within the frequency band defined by the two cutoff periods
|
|||
|
|
- Shorter cycles and longer trends are both rejected
|
|||
|
|
- This makes the oscillator highly selective
|
|||
|
|
|
|||
|
|
- **Divergence Analysis:**
|
|||
|
|
- Bullish divergence: price makes lower lows while DECO makes higher lows
|
|||
|
|
- Bearish divergence: price makes higher highs while DECO makes lower highs
|
|||
|
|
- Indicates potential trend reversal
|
|||
|
|
|
|||
|
|
- **Multiple Instance Analysis:**
|
|||
|
|
- Ehlers recommends using multiple DECO instances with different period pairs
|
|||
|
|
- Crossovers between instances with different coefficients can identify trend reversals
|
|||
|
|
|
|||
|
|
## Warmup Period
|
|||
|
|
|
|||
|
|
The indicator requires `longPeriod` bars before producing reliable output. The first two bars always output zero (insufficient price history for the 2-pole HP filter).
|
|||
|
|
|
|||
|
|
## Properties
|
|||
|
|
|
|||
|
|
- **Range:** Unbounded (oscillates around zero)
|
|||
|
|
- **Complexity:** O(1) per bar (pure IIR filter, no lookback buffer needed)
|
|||
|
|
- **Memory:** O(1) — only stores filter state variables
|
|||
|
|
|
|||
|
|
## Related Indicators
|
|||
|
|
|
|||
|
|
- **Decycler (DECYCLER):** The low-pass complement — removes cycles, keeps trend
|
|||
|
|
- **SSF-DSP:** Similar concept using Super Smooth Filters instead of HP filters
|
|||
|
|
- **Roofing Filter:** HP + SSF combination for cycle isolation
|
|||
|
|
- **BandPass Filter:** Ehlers' direct bandpass approach
|
|||
|
|
|
|||
|
|
## References
|
|||
|
|
|
|||
|
|
1. Ehlers, J. F. (2015). "Decyclers." *Technical Analysis of Stocks & Commodities*, September 2015.
|
|||
|
|
2. Ehlers, J. F. (2013). *Cycle Analytics for Traders*. Wiley. Chapter 4.
|