style patterns

This commit is contained in:
Miha Kralj
2026-01-25 16:01:45 -08:00
parent 2836f253c4
commit e59665c8f0
399 changed files with 6892 additions and 1323 deletions
+4 -1
View File
@@ -43,7 +43,10 @@ public class MidpointIndicator : Indicator, IWatchlistIndicator
protected override void OnUpdate(UpdateArgs args)
{
if (_midpoint == null || _selector == null) return;
if (_midpoint == null || _selector == null)
{
return;
}
var item = HistoricalData[0, SeekOriginHistory.End];
double value = _selector(item);
+15
View File
@@ -33,7 +33,9 @@ public sealed class Midpoint : AbstractBase
public Midpoint(int period)
{
if (period < 1)
{
throw new ArgumentException("Period must be >= 1", nameof(period));
}
_highest = new Highest(period);
_lowest = new Lowest(period);
@@ -116,11 +118,19 @@ public sealed class Midpoint : AbstractBase
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int period)
{
if (source.Length == 0)
{
throw new ArgumentException("Source cannot be empty", nameof(source));
}
if (output.Length < source.Length)
{
throw new ArgumentException("Output length must be >= source length", nameof(output));
}
if (period < 1)
{
throw new ArgumentException("Period must be >= 1", nameof(period));
}
int len = source.Length;
@@ -151,9 +161,14 @@ public sealed class Midpoint : AbstractBase
finally
{
if (rentedHigh != null)
{
System.Buffers.ArrayPool<double>.Shared.Return(rentedHigh);
}
if (rentedLow != null)
{
System.Buffers.ArrayPool<double>.Shared.Return(rentedLow);
}
}
}