{"record":{"id":"2bba0520453f59df","repo":"StockSharp/StockSharp","slug":"specified-argument-was-out-of-the-range-of-valid-v-2bba05","errorCode":null,"errorMessage":"Specified argument was out of the range of valid values. (Parameter 'parameters')","messagePattern":"Specified argument was out of the range of valid values\\. \\(Parameter 'parameters'\\)","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"Algo.Gpu/Indicators/GpuPriceChannelsCalculator.cs","lineNumber":149,"sourceCode":"\t{\n\t\t_kernel = Accelerator.LoadAutoGroupedStreamKernel\n\t\t\t<Index3D, ArrayView<GpuCandle>, ArrayView<GpuPriceChannelsResult>, ArrayView<int>, ArrayView<int>, ArrayView<GpuPriceChannelsParams>>(PriceChannelsKernel);\n\t}\n\n\t/// <inheritdoc />\n\tpublic override GpuPriceChannelsResult[][][] Calculate(GpuCandle[][] candlesSeries, GpuPriceChannelsParams[] parameters)\n\t{\n\t\tArgumentNullException.ThrowIfNull(candlesSeries);\n\t\tArgumentNullException.ThrowIfNull(parameters);\n\n\t\tif (candlesSeries.Length == 0)\n\t\t{\n\t\t\tthrow new ArgumentOutOfRangeException(nameof(candlesSeries));\n\t\t}\n\n\t\tif (parameters.Length == 0)\n\t\t{\n\t\t\tthrow new ArgumentOutOfRangeException(nameof(parameters));\n\t\t}\n\n\t\tvar seriesCount = candlesSeries.Length;\n\n\t\tvar totalSize = 0;\n\t\tvar seriesOffsets = new int[seriesCount];\n\t\tvar seriesLengths = new int[seriesCount];\n\n\t\tfor (var s = 0; s < seriesCount; s++)\n\t\t{\n\t\t\tseriesOffsets[s] = totalSize;\n\t\t\tvar len = candlesSeries[s]?.Length ?? 0;\n\t\t\tseriesLengths[s] = len;\n\t\t\ttotalSize += len;\n\t\t}\n\n\t\tvar flatCandles = new GpuCandle[totalSize];\n\t\tvar maxLen = 0;","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/StockSharp/StockSharp/blob/601a191de678bff83da28b14828f8885214ca71c/Algo.Gpu/Indicators/GpuPriceChannelsCalculator.cs#L131-L167","documentation":"GpuPriceChannelsCalculator.Calculate throws ArgumentOutOfRangeException on the 'parameters' guard when the parameters array is empty (Length == 0). The calculator cannot dispatch any GPU kernel without at least one parameter set, so it rejects the call at the public API boundary before allocating buffers or loading kernels.","triggerScenarios":"Calling Calculate(candlesSeries, new GpuPriceChannelsParams[0]) or Calculate(candlesSeries, Array.Empty<GpuPriceChannelsParams>()). Also triggered when a caller builds the parameters array from a filter/loop that yields zero elements.","commonSituations":"A batch-optimization loop filters parameters down to none; a config/UI passes an empty parameter list because no indicator period was selected; a default-initialized array was never populated before the call.","solutions":["Ensure the GpuPriceChannelsParams[] passed to Calculate contains at least one element before invoking.","If the caller legitimately has zero parameters, short-circuit and return an empty result instead of calling the GPU calculator.","Add a unit test asserting Calculate throws on an empty parameters array so the contract is locked."],"exampleFix":"// before\ncalc.Calculate(series, Array.Empty<GpuPriceChannelsParams>());\n// after\nif (parameters.Length == 0) return Array.Empty<GpuPriceChannelsResult[][]>();\ncalc.Calculate(series, parameters);","handlingStrategy":"validation","validationCode":"if (candlesSeries is null || candlesSeries.Length == 0) return Array.Empty<GpuPriceChannelsResult[][]>();\nif (parameters is null || parameters.Length == 0) return Array.Empty<GpuPriceChannelsResult[][]>();","typeGuard":"static bool HasParameters<T>(T[] parameters) => parameters is { Length: > 0 };","tryCatchPattern":null,"preventionTips":["Centralize pre-call validation in a helper that wraps every GPU calculator invocation.","Treat an empty parameters or series array as a no-op result, not an error, in batch pipelines.","Assert non-empty inputs in unit tests covering the Calculate contract."],"tags":["gpu","argument-validation","csharp","indicators","price-channels"],"backgroundTag":null,"analyzedSha":"601a191de678bff83da28b14828f8885214ca71c","analyzedAt":"2026-08-13T20:43:24.460Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}