diff --git a/src/a-d/Adx/Adx.Models.cs b/src/a-d/Adx/Adx.Models.cs index 783a741fd..9f65ac570 100644 --- a/src/a-d/Adx/Adx.Models.cs +++ b/src/a-d/Adx/Adx.Models.cs @@ -6,6 +6,7 @@ namespace Skender.Stock.Indicators; /// Gets the timestamp of the result. /// Gets the Positive Directional Indicator (PDI) value. /// Gets the Negative Directional Indicator (MDI) value. +/// Gets the Directional Index (DX) value. /// Gets the Average Directional Index (ADX) value. /// Gets the Average Directional Movement Rating (ADXR) value. [Serializable] @@ -14,6 +15,7 @@ public record AdxResult DateTime Timestamp, double? Pdi = null, double? Mdi = null, + double? Dx = null, double? Adx = null, double? Adxr = null ) : IReusable diff --git a/src/a-d/Adx/Adx.StaticSeries.cs b/src/a-d/Adx/Adx.StaticSeries.cs index 35d94dd7e..7a79cfcf2 100644 --- a/src/a-d/Adx/Adx.StaticSeries.cs +++ b/src/a-d/Adx/Adx.StaticSeries.cs @@ -166,6 +166,7 @@ private static List CalcAdx( Timestamp: q.Timestamp, Pdi: pdi, Mdi: mdi, + Dx: dx.NaN2Null(), Adx: adx.NaN2Null(), Adxr: adxr.NaN2Null()); diff --git a/tests/indicators/a-d/Adx/Adx.Calc.xlsx b/tests/indicators/a-d/Adx/Adx.Calc.xlsx index 67504cd44..bb8908c77 100644 Binary files a/tests/indicators/a-d/Adx/Adx.Calc.xlsx and b/tests/indicators/a-d/Adx/Adx.Calc.xlsx differ diff --git a/tests/indicators/a-d/Adx/Adx.StaticSeries.Tests.cs b/tests/indicators/a-d/Adx/Adx.StaticSeries.Tests.cs index ca0a5c213..c89d64a17 100644 --- a/tests/indicators/a-d/Adx/Adx.StaticSeries.Tests.cs +++ b/tests/indicators/a-d/Adx/Adx.StaticSeries.Tests.cs @@ -10,18 +10,39 @@ public override void Standard() // proper quantities Assert.AreEqual(502, results.Count); + Assert.AreEqual(488, results.Count(x => x.Dx != null)); Assert.AreEqual(475, results.Count(x => x.Adx != null)); Assert.AreEqual(462, results.Count(x => x.Adxr != null)); // sample values + AdxResult r13 = results[13]; + Assert.AreEqual(null, r13.Pdi); + Assert.AreEqual(null, r13.Mdi); + Assert.AreEqual(null, r13.Dx); + Assert.AreEqual(null, r13.Adx); + + AdxResult r14 = results[14]; + Assert.AreEqual(21.9669, r14.Pdi.Round(4)); + Assert.AreEqual(18.5462, r14.Mdi.Round(4)); + Assert.AreEqual(8.4433, r14.Dx.Round(4)); + Assert.AreEqual(null, r14.Adx); + AdxResult r19 = results[19]; Assert.AreEqual(21.0361, r19.Pdi.Round(4)); Assert.AreEqual(25.0124, r19.Mdi.Round(4)); + Assert.AreEqual(8.6351, r19.Dx.Round(4)); Assert.AreEqual(null, r19.Adx); + AdxResult r26 = results[26]; + Assert.AreEqual(null, r26.Adx); + + AdxResult r27 = results[27]; + Assert.AreEqual(15.9459, r27.Adx.Round(4)); + AdxResult r29 = results[29]; Assert.AreEqual(37.9719, r29.Pdi.Round(4)); Assert.AreEqual(14.1658, r29.Mdi.Round(4)); + Assert.AreEqual(45.6600, r29.Dx.Round(4)); Assert.AreEqual(19.7949, r29.Adx.Round(4)); AdxResult r39 = results[39]; @@ -33,12 +54,14 @@ public override void Standard() AdxResult r248 = results[248]; Assert.AreEqual(32.3167, r248.Pdi.Round(4)); Assert.AreEqual(18.2471, r248.Mdi.Round(4)); + Assert.AreEqual(27.8255, r248.Dx.Round(4)); Assert.AreEqual(30.5903, r248.Adx.Round(4)); Assert.AreEqual(29.1252, r248.Adxr.Round(4)); AdxResult r501 = results[501]; Assert.AreEqual(17.7565, r501.Pdi.Round(4)); Assert.AreEqual(31.1510, r501.Mdi.Round(4)); + Assert.AreEqual(27.3873, r501.Dx.Round(4)); Assert.AreEqual(34.2987, r501.Adx.Round(4)); }