mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-16 01:28: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:
+2
-27
@@ -1,5 +1,7 @@
|
||||
# HA: Heikin-Ashi
|
||||
|
||||
> *The trend is your friend — but only if the noise doesn't make you abandon it at the first bump.*
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Core |
|
||||
@@ -16,8 +18,6 @@
|
||||
- Requires `1` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The trend is your friend — but only if the noise doesn't make you abandon it at the first bump." — Every trader, eventually
|
||||
|
||||
HA transforms standard OHLC bars into smoothed Heikin-Ashi candles by averaging each component with its predecessor. The Close is the bar's four-price mean $(O+H+L+C)/4$, the Open is a recursive midpoint of the prior HA Open and HA Close, and High/Low are clamped extremes that guarantee the HA body always fits inside the HA wick. Unlike most indicators that reduce a bar to a single scalar, HA outputs a complete `TBar` — four smoothed prices per bar — making it a bar-to-bar transform rather than a bar-to-value reduction. The recursive Open gives HA an IIR character: each bar carries a decaying memory of the entire price history, which is what flattens trend noise but also why HA prices do not match any actual traded price.
|
||||
|
||||
## Historical Context
|
||||
@@ -100,31 +100,6 @@ $$\text{WarmupPeriod} = 1$$
|
||||
|
||||
HA is "hot" from bar 1. The seed bar uses $(O_0 + C_0)/2$ for HA_Open and produces valid output immediately. The recursive filter converges rapidly due to the $\beta = 0.5$ decay — after 7 bars, the contribution of the seed value is less than 0.4%.
|
||||
|
||||
### Pseudo-code
|
||||
|
||||
```
|
||||
function HA(bar, prevHaOpen, prevHaClose):
|
||||
o, h, l, c ← bar.Open, bar.High, bar.Low, bar.Close
|
||||
|
||||
// Substitute last-valid for non-finite inputs
|
||||
if !finite(o): o ← lastValidOpen
|
||||
if !finite(h): h ← lastValidHigh
|
||||
if !finite(l): l ← lastValidLow
|
||||
if !finite(c): c ← lastValidClose
|
||||
|
||||
haClose ← FMA(o + h, 0.25, (l + c) × 0.25)
|
||||
|
||||
if firstBar:
|
||||
haOpen ← (o + c) × 0.5
|
||||
else:
|
||||
haOpen ← (prevHaOpen + prevHaClose) × 0.5
|
||||
|
||||
haHigh ← max(h, haOpen, haClose)
|
||||
haLow ← min(l, haOpen, haClose)
|
||||
|
||||
return TBar(bar.Time, haOpen, haHigh, haLow, haClose, bar.Volume)
|
||||
```
|
||||
|
||||
### Output Interpretation
|
||||
|
||||
| Candle Pattern | Meaning |
|
||||
|
||||
Reference in New Issue
Block a user