{"record":{"id":"285060bbf67593f4","repo":"StockSharp/StockSharp","slug":"candlesseries-285060","errorCode":null,"errorMessage":"candlesSeries","messagePattern":"candlesSeries","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"Algo.Gpu/Indicators/GpuMomentumOfMovingAverageCalculator.cs","lineNumber":69,"sourceCode":"\t/// Initializes a new instance of the <see cref=\"GpuMomentumOfMovingAverageCalculator\"/> class.\n\t/// </summary>\n\t/// <param name=\"context\">ILGPU context.</param>\n\t/// <param name=\"accelerator\">ILGPU accelerator.</param>\n\tpublic GpuMomentumOfMovingAverageCalculator(Context context, Accelerator accelerator)\n\t\t: base(context, accelerator)\n\t{\n\t\t_paramsSeriesKernel = Accelerator.LoadAutoGroupedStreamKernel\n\t\t\t<Index2D, ArrayView<GpuCandle>, ArrayView<GpuIndicatorResult>, ArrayView<float>, ArrayView<int>, ArrayView<int>, ArrayView<GpuMomentumOfMovingAverageParams>, ArrayView<int>>(MomentumParamsSeriesKernel);\n\t}\n\n\t/// <inheritdoc />\n\tpublic override GpuIndicatorResult[][][] Calculate(GpuCandle[][] candlesSeries, GpuMomentumOfMovingAverageParams[] 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":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/StockSharp/StockSharp/blob/601a191de678bff83da28b14828f8885214ca71c/Algo.Gpu/Indicators/GpuMomentumOfMovingAverageCalculator.cs#L51-L87","documentation":"GpuMomentumOfMovingAverageCalculator.Calculate throws ArgumentOutOfRangeException(paramName=\"candlesSeries\") when the GpuCandle[][] array is empty. The pipeline flattens series, allocates device buffers (including an RoR float scratch buffer), and launches MomentumParamsSeriesKernel over (series x parameters); zero series makes the extent degenerate, so the guard rejects it.","triggerScenarios":"Calling Calculate with an empty series array from a batch aggregator that matched no instruments.","commonSituations":"No candles for the batch window; a symbol filter removing all series; an empty data-feed response forwarded to the GPU stage.","solutions":["Guard the caller: `if (candlesSeries.Length == 0) return Array.Empty<GpuIndicatorResult[][]>();`.","Ensure the data feed populated at least one series.","Short-circuit at the batch boundary when seriesCount is zero."],"exampleFix":"// before\ncalc.Calculate(seriesArray, parameters);\n\n// after\nif (seriesArray.Length == 0) return Array.Empty<GpuIndicatorResult[][]>();\ncalc.Calculate(seriesArray, parameters);","handlingStrategy":"validation","validationCode":"if (candlesSeries is null || candlesSeries.Length == 0)\n    return Array.Empty<GpuIndicatorResult[][]>();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize the series-emptiness check in the batch dispatcher.","Ensure the data feed populated at least one series.","Short-circuit no-data windows before the GPU stage."],"tags":["gpu","validation","argument","stocksharp","ilgpu","momentum-of-moving-average"],"backgroundTag":null,"analyzedSha":"601a191de678bff83da28b14828f8885214ca71c","analyzedAt":"2026-08-13T20:43:24.460Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}