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
+12 -5
View File
@@ -136,6 +136,9 @@ public sealed class Adosc : ITValuePublisher
return new TSeries(t, v);
}
// EMA compensator threshold (same as in Ema.cs)
private const double COMPENSATOR_THRESHOLD = 1e-10;
/// <summary>
/// Calculates ADOSC for the entire series using a new instance.
/// </summary>
@@ -149,9 +152,6 @@ public sealed class Adosc : ITValuePublisher
return adosc.Update(source);
}
// EMA compensator threshold (same as in Ema.cs)
private const double COMPENSATOR_THRESHOLD = 1e-10;
/// <summary>
/// Calculates ADOSC for the entire span using a single-pass algorithm.
/// Zero allocation for maximum performance.
@@ -165,7 +165,7 @@ public sealed class Adosc : ITValuePublisher
/// <param name="fastPeriod">Fast EMA period (default 3)</param>
/// <param name="slowPeriod">Slow EMA period (default 10)</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Calculate(ReadOnlySpan<double> high, ReadOnlySpan<double> low, ReadOnlySpan<double> close, ReadOnlySpan<double> volume, Span<double> output, int fastPeriod = 3, int slowPeriod = 10)
public static void Batch(ReadOnlySpan<double> high, ReadOnlySpan<double> low, ReadOnlySpan<double> close, ReadOnlySpan<double> volume, Span<double> output, int fastPeriod = 3, int slowPeriod = 10)
{
if (high.Length != low.Length || high.Length != close.Length ||
high.Length != volume.Length || high.Length != output.Length)
@@ -276,4 +276,11 @@ public sealed class Adosc : ITValuePublisher
output[i] = fastValue - slowValue;
}
}
}
public static (TSeries Results, Adosc Indicator) Calculate(TBarSeries source, int fastPeriod = 3, int slowPeriod = 10)
{
var indicator = new Adosc(fastPeriod, slowPeriod);
TSeries results = indicator.Update(source);
return (results, indicator);
}
}