StockSharp/StockSharp · error · ArgumentOutOfRangeException
parameters
Error message
parameters
What it means
The Gator Oscillator calculator computes a histogram showing the convergence and divergence of the Alligator indicator's jaw, teeth, and lips smoothed moving averages across one or more GpuGatorOscillatorParams parameter sets. Calculate parameterizes its 3DD kernel grid over both the candle-series count and the parameter-set count (series x parameters x candles), so a zero-length parameters array collapses one grid axis and leaves nothing to dispatch. ArgumentOutOfRangeException(nameof(parameters)) fires at the top of Calculate before the flattening loop, ensuring a fast failure rather than a meaningless GPU kernel launch.
Source
Thrown at Algo.Gpu/Indicators/GpuGatorOscillatorCalculator.cs:175
/// <param name="context">ILGPU context.</param>
/// <param name="accelerator">ILGPU accelerator.</param>
public GpuGatorOscillatorCalculator(Context context, Accelerator accelerator)
: base(context, accelerator)
{
_kernel = Accelerator.LoadAutoGroupedStreamKernel<Index3D, ArrayView<GpuCandle>, ArrayView<GpuGatorOscillatorResult>, ArrayView<int>, ArrayView<int>, ArrayView<GpuGatorOscillatorParams>>(CalculateKernel);
}
/// <inheritdoc />
public override GpuGatorOscillatorResult[][][] Calculate(GpuCandle[][] candlesSeries, GpuGatorOscillatorParams[] parameters)
{
ArgumentNullException.ThrowIfNull(candlesSeries);
ArgumentNullException.ThrowIfNull(parameters);
if (candlesSeries.Length == 0)
throw new ArgumentOutOfRangeException(nameof(candlesSeries));
if (parameters.Length == 0)
throw new ArgumentOutOfRangeException(nameof(parameters));
var seriesCount = candlesSeries.Length;
var totalSize = 0;
var seriesOffsets = new int[seriesCount];
var seriesLengths = new int[seriesCount];
var maxLen = 0;
for (var s = 0; s < seriesCount; s++)
{
seriesOffsets[s] = totalSize;
var len = candlesSeries[s]?.Length ?? 0;
seriesLengths[s] = len;
totalSize += len;
if (len > maxLen)
maxLen = len;
}
View on GitHub (pinned to 601a191de6)
Solutions
- Guard the call site: check parameters.Length > 0 before invoking Calculate.
- Verify the parameter generation or sweep logic produces at least one entry; add a sensible default parameter set as fallback.
- Validate configuration at startup: if the indicator parameter section is missing or empty, fail fast with a clear message naming the indicator.
- For user-driven parameter UI, enforce a minimum of one GpuGatorOscillatorParams before enabling the calculate action.
Example fix
// before -- throws ArgumentOutOfRangeException (ParamName: parameters)
var results = calculator.Calculate(candlesSeries, parameters);
// after -- guard before calling
if (parameters is null || parameters.Length == 0)
throw new ArgumentException(
$"At least one GpuGatorOscillatorParams set is required.", nameof(parameters));
var results = calculator.Calculate(candlesSeries, parameters); Defensive patterns
Strategy: validation
Validate before calling
// Pre-call validation for GpuGatorOscillatorCalculator.Calculate
if (parameters is null || parameters.Length == 0)
throw new ArgumentException(
$"At least one GpuGatorOscillatorParams set is required.", nameof(parameters)); Type guard
static bool HasParameterSets(GpuGatorOscillatorParams[]? parameters) =>
parameters is { Length: > 0 }; Try / catch
GpuGatorOscillatorResult[][][] results;
try
{
results = calculator.Calculate(candlesSeries, parameters);
}
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "parameters")
{
logger.LogWarning("GpuGatorOscillatorCalculator: parameters array was empty, returning empty results");
results = Array.Empty<GpuGatorOscillatorResult[][][]>();
} Prevention
- Validate parameter arrays at configuration load time, not just at calculation time.
- Enforce a minimum of one parameter set in parameter builder and factory methods.
- Add a startup health check verifying each configured indicator has non-empty parameters.
- Use a shared guard helper (e.g., RequireNonEmpty) and call it consistently across all indicator calculators.
When it happens
Trigger: Calling Calculate with a GpuGatorOscillatorParams[] whose Length is 0 (e.g., calculator.Calculate(candlesSeries, Array.Empty<GpuGatorOscillatorParams>())). Also occurs when a parameter sweep or configuration loader produces zero entries and the empty array is passed through without a count guard.
Common situations: A parameter grid-search where validation rules filtered out all candidates; a configuration file with no parameter section for this indicator; a default-parameter factory with an off-by-one or early-return bug; a user-facing settings UI that saved zero parameter sets; JSON deserialization where the GpuGatorOscillatorParams array key was absent and defaulted to empty.
Related errors
AI-assisted analysis of StockSharp/StockSharp@601a191de6 (2026-08-13).
Data as JSON: /api/errors/5904cecb881fd648.
Report an issue: GitHub.