mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-19 11: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 @@
|
||||
# UBANDS: Ehlers Ultimate Bands
|
||||
|
||||
> *Ehlers' ultimate bands apply cycle-aware smoothing to define an envelope that resonates with dominant frequency.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Channel |
|
||||
@@ -107,47 +109,6 @@ $$
|
||||
|
||||
Cutoff frequency: approximately $f_c \approx 1/(2\pi n)$ cycles per bar. Rolloff: 12 dB/octave.
|
||||
|
||||
### Pseudo-code
|
||||
|
||||
```
|
||||
function ubands(source[], period, multiplier):
|
||||
// precompute USF coefficients
|
||||
arg = sqrt(2) * pi / period
|
||||
c2 = 2 * exp(-arg) * cos(arg)
|
||||
c3 = -exp(-2 * arg)
|
||||
c1 = (1 + c2 - c3) / 4
|
||||
|
||||
usf_prev1 = NaN, usf_prev2 = NaN
|
||||
|
||||
for each bar t:
|
||||
s0 = source[t]
|
||||
s1 = source[t-1] // or s0 if unavailable
|
||||
s2 = source[t-2] // or s1 if unavailable
|
||||
|
||||
if usf not initialized:
|
||||
usf = s0
|
||||
else:
|
||||
usf = (1 - c1)*s0 + (2*c1 - c2)*s1
|
||||
- (c1 + c3)*s2 + c2*usf_prev1 + c3*usf_prev2
|
||||
|
||||
usf_prev2 = usf_prev1
|
||||
usf_prev1 = usf
|
||||
|
||||
// RMS of residuals over window
|
||||
sum_sq = 0, count = 0
|
||||
for i = 0 to period-1:
|
||||
r = source[t-i] - usf_at[t-i] // residual at bar t-i
|
||||
if r is valid:
|
||||
sum_sq += r * r
|
||||
count += 1
|
||||
|
||||
rms = count > 0 ? sqrt(sum_sq / count) : 0
|
||||
upper = usf + multiplier * rms
|
||||
lower = usf - multiplier * rms
|
||||
|
||||
emit (upper, usf, lower)
|
||||
```
|
||||
|
||||
### RMS vs Standard Deviation
|
||||
|
||||
Standard deviation measures dispersion around the mean: $\sigma = \sqrt{E[(X - \mu)^2]}$. RMS measures dispersion around zero: $\text{RMS} = \sqrt{E[X^2]}$. Since the residuals $r_t = P_t - \text{USF}_t$ are already deviations from the smooth centerline, RMS is the correct measure. When the mean of residuals is zero (as it approximately is for a well-fitted filter), RMS equals standard deviation.
|
||||
|
||||
Reference in New Issue
Block a user