{"record":{"id":"7e05f430197b7edd","repo":"StockSharp/StockSharp","slug":"specified-argument-was-out-of-the-range-of-valid-v-7e05f4","errorCode":null,"errorMessage":"Specified argument was out of the range of valid values. (Parameter 'candlesSeries')","messagePattern":"Specified argument was out of the range of valid values\\. \\(Parameter 'candlesSeries'\\)","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"Algo.Gpu/Indicators/GpuPriceVolumeTrendCalculator.cs","lineNumber":44,"sourceCode":"\t/// Initializes a new instance of the <see cref=\"GpuPriceVolumeTrendCalculator\"/> class.\n\t/// </summary>\n\t/// <param name=\"context\">ILGPU context.</param>\n\t/// <param name=\"accelerator\">ILGPU accelerator.</param>\n\tpublic GpuPriceVolumeTrendCalculator(Context context, Accelerator accelerator)\n\t\t: base(context, accelerator)\n\t{\n\t\t_kernel = Accelerator.LoadAutoGroupedStreamKernel\n\t\t\t<Index2D, ArrayView<GpuCandle>, ArrayView<GpuIndicatorResult>, ArrayView<int>, ArrayView<int>, ArrayView<GpuPriceVolumeTrendParams>>(PriceVolumeTrendParamsSeriesKernel);\n\t}\n\n\t/// <inheritdoc />\n\tpublic override GpuIndicatorResult[][][] Calculate(GpuCandle[][] candlesSeries, GpuPriceVolumeTrendParams[] parameters)\n\t{\n\t\tArgumentNullException.ThrowIfNull(candlesSeries);\n\t\tArgumentNullException.ThrowIfNull(parameters);\n\n\t\tif (candlesSeries.Length == 0)\n\t\t\tthrow new ArgumentOutOfRangeException(nameof(candlesSeries));\n\n\t\tif (parameters.Length == 0)\n\t\t\tthrow new ArgumentOutOfRangeException(nameof(parameters));\n\n\t\tvar seriesCount = candlesSeries.Length;\n\n\t\t// Flatten input\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}","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/StockSharp/StockSharp/blob/601a191de678bff83da28b14828f8885214ca71c/Algo.Gpu/Indicators/GpuPriceVolumeTrendCalculator.cs#L26-L62","documentation":"GpuPriceVolumeTrendCalculator.Calculate throws ArgumentOutOfRangeException on the 'candlesSeries' guard when the outer series array is empty (Length == 0). This is the array-of-series, not an individual candle array: a null inner series is tolerated via `candlesSeries[s]?.Length ?? 0`, but a completely empty outer array leaves nothing to process and is rejected before GPU buffer allocation.","triggerScenarios":"Calling Calculate(new GpuCandle[0][], parameters) or Calculate(Array.Empty<GpuCandle[]>(), parameters). Also when a multi-symbol batch ends up with zero symbols after filtering.","commonSituations":"A symbol universe filter removes every symbol; a date-range query returns no candles so the caller passes an empty series array; a test harness forgets to seed candle data.","solutions":["Pass a candlesSeries array containing at least one (possibly empty or null) inner series, or skip the call entirely when there are no series.","If you intend 'nothing to do', return an empty result from the caller rather than calling the GPU calculator.","Validate the symbol universe upstream so an empty batch is handled before reaching Calculate."],"exampleFix":"// before\ncalc.Calculate(Array.Empty<GpuCandle[]>(), parameters);\n// after\nif (candlesSeries.Length == 0) return Array.Empty<GpuIndicatorResult[][]>();\ncalc.Calculate(candlesSeries, parameters);","handlingStrategy":"validation","validationCode":"if (candlesSeries is null || candlesSeries.Length == 0) return Array.Empty<GpuIndicatorResult[][]>();","typeGuard":"static bool HasSeries(GpuCandle[][] series) => series is { Length: > 0 };","tryCatchPattern":null,"preventionTips":["Guard the series batch at the pipeline boundary before reaching any GPU calculator.","Distinguish an empty outer array (rejected) from null inner series (tolerated).","Log when a symbol filter reduces the universe to zero so it is visible upstream."],"tags":["gpu","argument-validation","csharp","indicators","price-volume-trend"],"backgroundTag":null,"analyzedSha":"601a191de678bff83da28b14828f8885214ca71c","analyzedAt":"2026-08-13T20:43:24.460Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}