mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-22 20:48:04 +00:00
validation and profiles
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# HT_TRENDMODE: Hilbert Transform Trend vs Cycle Mode
|
||||
# HT_TRENDMODE: Hilbert Transform Trend vs Cycle Mode
|
||||
|
||||
The Hilbert Transform Trend Mode indicator is a binary regime classifier that determines whether price action is dominated by trending behavior (output = 1) or cyclical/mean-reverting behavior (output = 0). It uses the full Ehlers Hilbert Transform pipeline — 4-bar WMA smoothing, Hilbert FIR filters, homodyne discriminator for period estimation, DC phase extraction, and SineWave indicators — then applies four decision criteria to classify the current regime. The implementation follows TA-Lib's Ehlers-faithful algorithm from the February 2002 publication. Output is discrete {0, 1}, making it a direct strategy selector: deploy trend-following logic when mode = 1, and mean-reversion logic when mode = 0.
|
||||
|
||||
@@ -151,6 +151,44 @@ On each bar (price, isNew):
|
||||
| Long run of 1s | Strong, sustained trend |
|
||||
| Rapid 0/1 flipping | Transitional/choppy — reduce exposure |
|
||||
|
||||
## Performance Profile
|
||||
|
||||
### Operation Count (Streaming Mode)
|
||||
|
||||
HtTrendmode uses the Hilbert Transform DC Period estimation and compares it against a threshold to output binary trend/cycle mode.
|
||||
|
||||
**Post-warmup steady state (per bar):**
|
||||
|
||||
| Operation | Count | Cost (cycles) | Subtotal |
|
||||
| :--- | :---: | :---: | :---: |
|
||||
| Hilbert FIR coefficients × 4 (InPhase, Quad) | 8 | 3 | 24 |
|
||||
| Phase accumulator update (ATAN2 equivalent) | 1 | 20 | 20 |
|
||||
| Period smoothing (EMA on period estimate) | 2 | 4 | 8 |
|
||||
| Trend period threshold comparison | 1 | 1 | 1 |
|
||||
| History buffer shifts × 4 | 4 | 1 | 4 |
|
||||
| **Total** | **16** | — | **~57 cycles** |
|
||||
|
||||
The ATAN2-equivalent phase computation is the dominant cost. For default parameters: ~57 cycles per bar.
|
||||
|
||||
### Batch Mode (SIMD Analysis)
|
||||
|
||||
| Operation | Vectorizable? | Notes |
|
||||
| :--- | :---: | :--- |
|
||||
| Hilbert FIR (windowed taps) | Partial | Each tap independent; cross-bar state dependency limits |
|
||||
| Period EMA smoothing | **No** | Recursive IIR — sequential |
|
||||
| Threshold comparison | Yes | VCMPPD |
|
||||
|
||||
The recursive EMA smoothing of the period estimate blocks full vectorization.
|
||||
|
||||
### Quality Metrics
|
||||
|
||||
| Metric | Score | Notes |
|
||||
| :--- | :---: | :--- |
|
||||
| **Accuracy** | 7/10 | Phase estimation inherent noise; binary output loses detail |
|
||||
| **Timeliness** | 6/10 | Hilbert requires ~32 bar warmup for phase stabilization |
|
||||
| **Smoothness** | 10/10 | Binary 0/1 output — maximally smooth |
|
||||
| **Noise Rejection** | 7/10 | EMA-smoothed period estimate reduces mode-flip chatter |
|
||||
|
||||
## Resources
|
||||
|
||||
- Ehlers, J.F. — "The Instantaneous Trendline" (February 2002)
|
||||
|
||||
Reference in New Issue
Block a user