StockSharp/StockSharp · error · ArgumentOutOfRangeException

Specified argument was out of the range of valid values. (Pa

Error message

Specified argument was out of the range of valid values. (Parameter 'parameters')

What it means

GpuNickRypockTrailingReverseCalculator.Calculate throws ArgumentOutOfRangeException when the parameters array (GpuNickRypockTrailingReverseParams[]) is empty. Each parameter set defines trailing-reverse sensitivity; with zero sets there is nothing to compute, so the guard surfaces the issue.

Source

Thrown at Algo.Gpu/Indicators/GpuNickRypockTrailingReverseCalculator.cs:72

	/// <param name="accelerator">ILGPU accelerator.</param>
	public GpuNickRypockTrailingReverseCalculator(Context context, Accelerator accelerator)
		: base(context, accelerator)
	{
		_kernel = Accelerator.LoadAutoGroupedStreamKernel
				<Index2D, ArrayView<GpuCandle>, ArrayView<GpuIndicatorResult>, ArrayView<int>, ArrayView<int>, ArrayView<GpuNickRypockTrailingReverseParams>>(NickRypockTrailingReverseParamsSeriesKernel);
	}

	/// <inheritdoc />
	public override GpuIndicatorResult[][][] Calculate(GpuCandle[][] candlesSeries, GpuNickRypockTrailingReverseParams[] 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;

		// Flatten input series
		var totalSize = 0;
		var seriesOffsets = new int[seriesCount];
		var seriesLengths = new int[seriesCount];

		for (var s = 0; s < seriesCount; s++)
		{
			seriesOffsets[s] = totalSize;
			var len = candlesSeries[s]?.Length ?? 0;
			seriesLengths[s] = len;
			totalSize += len;
		}

		var flatCandles = new GpuCandle[totalSize];
		var offset = 0;

View on GitHub (pinned to 601a191de6)

Solutions

  1. Verify parameters.Length > 0 before calling Calculate
  2. Supply a default parameter set when none are configured
  3. Inspect the config loading path for silent empty-array returns

Example fix

// before
var results = calculator.Calculate(candlesSeries, parameters);

// after
if (parameters is null || parameters.Length == 0)
    throw new InvalidOperationException("No Nick Rypock parameter sets configured.");
var results = calculator.Calculate(candlesSeries, parameters);
Defensive patterns

Strategy: validation

Validate before calling

// Validate before calling GpuNickRypockTrailingReverseCalculator.Calculate
if (parameters is null || parameters.Length == 0)
{
    throw new InvalidOperationException("At least one Nick Rypock parameter set is required.");
}

Type guard

static bool IsValidParameters(GpuNickRypockTrailingReverseParams[] parameters) =>
    parameters is { Length: > 0 };

Try / catch

try
{
    var results = calculator.Calculate(candlesSeries, parameters);
}
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == nameof(parameters))
{
    logger.LogWarning("Empty parameters passed to Nick Rypock calculator");
    return Array.Empty<GpuIndicatorResult[][]>();
}

Prevention

When it happens

Trigger: Calling Calculate with Array.Empty<GpuNickRypockTrailingReverseParams>() or a zero-length parameters array.

Common situations: Nick Rypock config not loaded; parameter sweep excluded all configs; deserialization bug produced an empty array from a valid config file.

Related errors


AI-assisted analysis of StockSharp/StockSharp@601a191de6 (2026-08-13). Data as JSON: /api/errors/89bc1a091c680d8c. Report an issue: GitHub.