{"record":{"id":"2603dc4e0c3da60f","repo":"StockSharp/StockSharp","slug":"parameters-2603dc","errorCode":null,"errorMessage":"parameters","messagePattern":"parameters","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"Algo.Gpu/Indicators/GpuTemaCalculator.cs","lineNumber":65,"sourceCode":"\t/// <param name=\"accelerator\">ILGPU accelerator.</param>\n\tpublic GpuTemaCalculator(Context context, Accelerator accelerator)\n\t\t: base(context, accelerator)\n\t{\n\t\t_kernel = Accelerator.LoadAutoGroupedStreamKernel\n\t\t\t\t<Index2D, ArrayView<GpuCandle>, ArrayView<GpuIndicatorResult>, ArrayView<int>, ArrayView<int>, ArrayView<GpuTemaParams>>(TemaParamsSeriesKernel);\n\t}\n\n\t/// <inheritdoc />\n\tpublic override GpuIndicatorResult[][][] Calculate(GpuCandle[][] candlesSeries, GpuTemaParams[] 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}\n\n\t\tvar flatCandles = new GpuCandle[totalSize];\n\t\tvar offset = 0;","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/StockSharp/StockSharp/blob/601a191de678bff83da28b14828f8885214ca71c/Algo.Gpu/Indicators/GpuTemaCalculator.cs#L47-L83","documentation":"GpuTemaCalculator.Calculate throws ArgumentOutOfRangeException(nameof(parameters)) at line 65 when the GpuTemaParams[] array is empty. The params array sizes the kernel grid and output buffer (totalSize * parameters.Length); an empty array produces a degenerate zero-extent launch, so it is rejected before flattening and GPU allocation.","triggerScenarios":"Calling Calculate with parameters = Array.Empty<GpuTemaParams>(). Occurs when TEMA parameter generation yields nothing or a config list is empty.","commonSituations":"Empty parameters config; parameter sweep with no combos; deserialized empty JSON array; UI flow removing all TEMA parameter sets.","solutions":["Pass a GpuTemaParams[] with at least one element.","Short-circuit upstream when the params list is empty.","Validate parameter generation/config so empty results are explicit.","Caller guard: if (parameters.Length == 0) return empty;"],"exampleFix":"// before\ncalc.Calculate(candlesSeries, Array.Empty<GpuTemaParams>());\n\n// after\nif (parameters.Length == 0) return Array.Empty<GpuIndicatorResult[][]>();\ncalc.Calculate(candlesSeries, parameters);","handlingStrategy":"validation","validationCode":"if (parameters is null || parameters.Length == 0)\n    throw new ArgumentException(\"At least one GpuTemaParams is required.\", nameof(parameters));","typeGuard":"static bool HasParameters<T>(T[] parameters) => parameters is { Length: > 0 };","tryCatchPattern":"try { result = calc.Calculate(candlesSeries, parameters); }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"parameters\")\n{ /* log empty params; skip or default */ }","preventionTips":["Validate parameters.Length > 0 before calling Calculate.","Make param generation surface empty results explicitly.","Unit-test the empty-params throw contract.","Never forward a swept params array without a count check."],"tags":["argumentexception","gpu","ilgpu","validation","tema","params"],"backgroundTag":null,"analyzedSha":"601a191de678bff83da28b14828f8885214ca71c","analyzedAt":"2026-08-13T20:43:24.460Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}