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,5 +1,7 @@
|
||||
# TTM_TREND: TTM Trend
|
||||
|
||||
> *The simplest trend indicator is the one you actually follow.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Dynamic |
|
||||
@@ -16,8 +18,6 @@
|
||||
- Requires `> 2` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The simplest trend indicator is the one you actually follow."
|
||||
|
||||
John Carter's TTM Trend uses a fast EMA (default period 6) applied to typical price (HLC/3) to determine short-term trend direction via slope sign. Output is a ternary trend state: +1 (bullish, EMA rising), -1 (bearish, EMA falling), or 0 (neutral, EMA unchanged). The indicator requires only 2 bars warmup, runs at O(1) per bar with O(1) space, and produces zero allocations in the hot path.
|
||||
|
||||
## Historical Context
|
||||
@@ -75,36 +75,6 @@ This percentage rate-of-change quantifies how aggressively the trend is moving.
|
||||
|:----------|:-----|:--------|:-----------|:------------|
|
||||
| period | int | 6 | > 0 | EMA lookback period (very fast by default) |
|
||||
|
||||
### Pseudo-code
|
||||
|
||||
```
|
||||
TTM_TREND(bar, period=6):
|
||||
|
||||
tp = (bar.High + bar.Low + bar.Close) / 3
|
||||
alpha = 2.0 / (period + 1)
|
||||
|
||||
if count == 0:
|
||||
ema_val = tp
|
||||
else:
|
||||
ema_val = FMA(alpha, tp - ema_val, ema_val)
|
||||
|
||||
// Trend direction from slope sign
|
||||
if count >= 1:
|
||||
if ema_val > prev_ema:
|
||||
trend = +1
|
||||
else if ema_val < prev_ema:
|
||||
trend = -1
|
||||
else:
|
||||
trend = 0
|
||||
|
||||
strength = abs(ema_val - prev_ema) / prev_ema * 100
|
||||
|
||||
prev_ema = ema_val
|
||||
count += 1
|
||||
|
||||
return (ema_val, trend, strength)
|
||||
```
|
||||
|
||||
### Period Selection
|
||||
|
||||
The default period of 6 makes TTM Trend extremely fast-reacting. The EMA half-life is approximately $\ln(2) / \ln(1 + 2/N) \approx 2.4$ bars for $N = 6$. This means the indicator responds within 2-3 bars of a price shift. Longer periods (12, 20) reduce whipsaws but delay detection. Carter's design intent was maximum responsiveness, with noise filtering delegated to companion indicators (Squeeze, Wave).
|
||||
|
||||
Reference in New Issue
Block a user