normalization of methods

This commit is contained in:
Miha Kralj
2026-02-10 21:33:16 -08:00
parent 915d7a007b
commit 6d6259a47d
527 changed files with 10525 additions and 2123 deletions
+10 -3
View File
@@ -299,7 +299,7 @@ public sealed class Dx : ITValuePublisher
var v = new double[len];
// Use the static Calculate method for performance
Calculate(source.High.Values, source.Low.Values, source.Close.Values, _period, v);
Batch(source.High.Values, source.Low.Values, source.Close.Values, _period, v);
// Create lists for TSeries
var tList = new List<long>(len);
@@ -356,7 +356,7 @@ public sealed class Dx : ITValuePublisher
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Calculate(ReadOnlySpan<double> high, ReadOnlySpan<double> low, ReadOnlySpan<double> close, int period, Span<double> destination)
public static void Batch(ReadOnlySpan<double> high, ReadOnlySpan<double> low, ReadOnlySpan<double> close, int period, Span<double> destination)
{
int len = high.Length;
if (len < period + 1)
@@ -419,7 +419,7 @@ public sealed class Dx : ITValuePublisher
var len = source.Count;
var v = new double[len];
Calculate(source.High.Values, source.Low.Values, source.Close.Values, period, v);
Batch(source.High.Values, source.Low.Values, source.Close.Values, period, v);
var tList = new List<long>(len);
var times = source.Open.Times;
@@ -430,4 +430,11 @@ public sealed class Dx : ITValuePublisher
return new TSeries(tList, [.. v]);
}
public static (TSeries Results, Dx Indicator) Calculate(TBarSeries source, int period = 14)
{
var indicator = new Dx(period);
TSeries results = indicator.Update(source);
return (results, indicator);
}
}