feat: add MADH (Ehlers Moving Average Difference with Hann) indicator

This commit is contained in:
Miha Kralj
2026-03-17 13:48:34 -07:00
parent 4fa29c04b7
commit b4523b5cca
16 changed files with 1410 additions and 0 deletions
+1
View File
@@ -654,6 +654,7 @@ packages = ["quantalib"]
| dosc | `Dosc` | A | rsiPeriod, ema1Period, ema2Period, sigPeriod |
| dso | `Dso` | A | period |
| rsih | `Rsih` | A | period |
| madh | `Madh` | A | shortLength, dominantCycle |
| dymi | `Dymi` | A | basePeriod, shortPeriod, longPeriod... |
| er | `Er` | A | period |
| fisher | `Fisher` | A | period, alpha |
+1
View File
@@ -450,6 +450,7 @@ HAS_DECO = _bind("qtl_deco", [_dp, _ci, _dp, _ci, _ci])
HAS_DOSC = _bind("qtl_dosc", [_dp, _ci, _dp, _ci, _ci, _ci, _ci])
HAS_DSO = _bind("qtl_dso", [_dp, _ci, _dp, _ci])
HAS_RSIH = _bind("qtl_rsih", [_dp, _ci, _dp, _ci])
HAS_MADH = _bind("qtl_madh", [_dp, _ci, _dp, _ci, _ci])
HAS_DYMI = _bind("qtl_dymi", [_dp, _ci, _dp, _ci, _ci, _ci, _ci, _ci])
HAS_CRSI = _bind("qtl_crsi", [_dp, _ci, _dp, _ci, _ci, _ci])
HAS_BBB = _bind("qtl_bbb", [_dp, _ci, _dp, _ci, _cd])
+8
View File
@@ -51,6 +51,7 @@ __all__ = [
"dosc",
"dso",
"rsih",
"madh",
"dymi",
"crsi",
"bbb",
@@ -565,6 +566,13 @@ def rsih(close: object, period: int = 14, offset: int = 0, **kwargs) -> object:
return _wrap(dst, idx, f"RSIH_{period}", "oscillators", offset)
def madh(close: object, shortLength: int = 8, dominantCycle: int = 27, offset: int = 0, **kwargs) -> object:
"""Ehlers Moving Average Difference with Hann Windowing."""
src, idx = _arr(close); n = len(src); dst = _out(n)
_check(_lib.qtl_madh(_ptr(src), n, _ptr(dst), int(shortLength), int(dominantCycle)))
return _wrap(dst, idx, f"MADH_{shortLength}_{dominantCycle}", "oscillators", int(offset))
def dymi(close: object, base_period: int = 14, short_period: int = 5,
long_period: int = 10, min_period: int = 3, max_period: int = 30,
offset: int = 0, **kwargs) -> object:
+10
View File
@@ -438,6 +438,16 @@ public static unsafe partial class Exports
catch { return StatusCodes.QTL_ERR_INTERNAL; }
}
// Madh: Pattern A (src, out, int shortLength, int dominantCycle)
[UnmanagedCallersOnly(EntryPoint = "qtl_madh")]
public static int QtlMadh(double* src, int n, double* dst, int shortLength, int dominantCycle)
{
int v = Chk1(src, dst, n); if (v != 0) return v;
if (shortLength < 1 || dominantCycle < 2) return StatusCodes.QTL_ERR_INVALID_PARAM;
try { Madh.Batch(Src(src, n), Dst(dst, n), shortLength, dominantCycle); return StatusCodes.QTL_OK; }
catch { return StatusCodes.QTL_ERR_INTERNAL; }
}
// Dymi: Pattern A (src, out, int p1..p5)
[UnmanagedCallersOnly(EntryPoint = "qtl_dymi")]
public static int QtlDymi(double* src, int n, double* dst, int p1, int p2, int p3, int p4, int p5)