mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-01 11:17:46 +00:00
feat: add USI (Ehlers Ultimate Strength Index) - TASC Nov 2024
This commit is contained in:
@@ -458,6 +458,7 @@ HAS_BBB = _bind("qtl_bbb", [_dp, _ci, _dp, _ci, _cd])
|
||||
HAS_BBI = _bind("qtl_bbi", [_dp, _ci, _dp, _ci, _ci, _ci, _ci])
|
||||
HAS_DEM = _bind("qtl_dem", [_dp, _dp, _ci, _dp, _ci])
|
||||
HAS_BRAR = _bind("qtl_brar", [_dp, _dp, _dp, _dp, _ci, _dp, _dp, _ci])
|
||||
HAS_USI = _bind("qtl_usi", [_dp, _ci, _dp, _ci])
|
||||
|
||||
# ── Trends — FIR (Exports.cs — manual) ──
|
||||
HAS_SMA = _bind("qtl_sma", [_dp, _ci, _dp, _ci])
|
||||
|
||||
@@ -639,3 +639,11 @@ def brar(open: object, high: object, low: object, close: object,
|
||||
n = len(o); br = _out(n); ar = _out(n)
|
||||
_check(_lib.qtl_brar(_ptr(o), _ptr(h), _ptr(l), _ptr(c), n, _ptr(br), _ptr(ar), length))
|
||||
return _wrap_multi({f"BR_{length}": br, f"AR_{length}": ar}, idx, "oscillators", offset)
|
||||
|
||||
|
||||
def usi(close: object, period: int = 28, offset: int = 0, **kwargs) -> object:
|
||||
"""Ehlers Ultimate Strength Index (USI)."""
|
||||
period = int(period); offset = int(offset)
|
||||
c, idx = _arr(close); n = len(c); dst = _out(n)
|
||||
_check(_lib.qtl_usi(_ptr(c), n, _ptr(dst), period))
|
||||
return _wrap(dst, idx, f"USI_{period}", "oscillators", int(offset))
|
||||
|
||||
@@ -517,6 +517,16 @@ public static unsafe partial class Exports
|
||||
catch { return StatusCodes.QTL_ERR_INTERNAL; }
|
||||
}
|
||||
|
||||
// Usi: Pattern A (src, out, int period)
|
||||
[UnmanagedCallersOnly(EntryPoint = "qtl_usi")]
|
||||
public static int QtlUsi(double* src, int n, double* dst, int period)
|
||||
{
|
||||
int v = Chk1(src, dst, n); if (v != 0) return v;
|
||||
v = ChkPeriod(period); if (v != 0) return v;
|
||||
try { Usi.Batch(Src(src, n), Dst(dst, n), period); return StatusCodes.QTL_OK; }
|
||||
catch { return StatusCodes.QTL_ERR_INTERNAL; }
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════
|
||||
// §8.4 Trends — FIR
|
||||
// ═══════════════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user