{"record":{"id":"5904cecb881fd648","repo":"StockSharp/StockSharp","slug":"parameters-5904ce","errorCode":null,"errorMessage":"parameters","messagePattern":"parameters","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"Algo.Gpu/Indicators/GpuGatorOscillatorCalculator.cs","lineNumber":175,"sourceCode":"\t/// <param name=\"context\">ILGPU context.</param>\n\t/// <param name=\"accelerator\">ILGPU accelerator.</param>\n\tpublic GpuGatorOscillatorCalculator(Context context, Accelerator accelerator)\n\t\t: base(context, accelerator)\n\t{\n\t\t_kernel = Accelerator.LoadAutoGroupedStreamKernel<Index3D, ArrayView<GpuCandle>, ArrayView<GpuGatorOscillatorResult>, ArrayView<int>, ArrayView<int>, ArrayView<GpuGatorOscillatorParams>>(CalculateKernel);\n\t}\n\n\t/// <inheritdoc />\n\tpublic override GpuGatorOscillatorResult[][][] Calculate(GpuCandle[][] candlesSeries, GpuGatorOscillatorParams[] 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\tvar totalSize = 0;\n\t\tvar seriesOffsets = new int[seriesCount];\n\t\tvar seriesLengths = new int[seriesCount];\n\t\tvar maxLen = 0;\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\tif (len > maxLen)\n\t\t\t\tmaxLen = len;\n\t\t}\n","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/StockSharp/StockSharp/blob/601a191de678bff83da28b14828f8885214ca71c/Algo.Gpu/Indicators/GpuGatorOscillatorCalculator.cs#L157-L193","documentation":"The Gator Oscillator calculator computes a histogram showing the convergence and divergence of the Alligator indicator's jaw, teeth, and lips smoothed moving averages across one or more GpuGatorOscillatorParams parameter sets. Calculate parameterizes its 3DD kernel grid over both the candle-series count and the parameter-set count (series x parameters x candles), so a zero-length parameters array collapses one grid axis and leaves nothing to dispatch. ArgumentOutOfRangeException(nameof(parameters)) fires at the top of Calculate before the flattening loop, ensuring a fast failure rather than a meaningless GPU kernel launch.","triggerScenarios":"Calling Calculate with a GpuGatorOscillatorParams[] whose Length is 0 (e.g., calculator.Calculate(candlesSeries, Array.Empty<GpuGatorOscillatorParams>())). Also occurs when a parameter sweep or configuration loader produces zero entries and the empty array is passed through without a count guard.","commonSituations":"A parameter grid-search where validation rules filtered out all candidates; a configuration file with no parameter section for this indicator; a default-parameter factory with an off-by-one or early-return bug; a user-facing settings UI that saved zero parameter sets; JSON deserialization where the GpuGatorOscillatorParams array key was absent and defaulted to empty.","solutions":["Guard the call site: check parameters.Length > 0 before invoking Calculate.","Verify the parameter generation or sweep logic produces at least one entry; add a sensible default parameter set as fallback.","Validate configuration at startup: if the indicator parameter section is missing or empty, fail fast with a clear message naming the indicator.","For user-driven parameter UI, enforce a minimum of one GpuGatorOscillatorParams before enabling the calculate action."],"exampleFix":"// before -- throws ArgumentOutOfRangeException (ParamName: parameters)\nvar results = calculator.Calculate(candlesSeries, parameters);\n\n// after -- guard before calling\nif (parameters is null || parameters.Length == 0)\n    throw new ArgumentException(\n        $\"At least one GpuGatorOscillatorParams set is required.\", nameof(parameters));\nvar results = calculator.Calculate(candlesSeries, parameters);","handlingStrategy":"validation","validationCode":"// Pre-call validation for GpuGatorOscillatorCalculator.Calculate\nif (parameters is null || parameters.Length == 0)\n    throw new ArgumentException(\n        $\"At least one GpuGatorOscillatorParams set is required.\", nameof(parameters));","typeGuard":"static bool HasParameterSets(GpuGatorOscillatorParams[]? parameters) =>\n    parameters is { Length: > 0 };","tryCatchPattern":"GpuGatorOscillatorResult[][][] results;\ntry\n{\n    results = calculator.Calculate(candlesSeries, parameters);\n}\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"parameters\")\n{\n    logger.LogWarning(\"GpuGatorOscillatorCalculator: parameters array was empty, returning empty results\");\n    results = Array.Empty<GpuGatorOscillatorResult[][][]>();\n}","preventionTips":["Validate parameter arrays at configuration load time, not just at calculation time.","Enforce a minimum of one parameter set in parameter builder and factory methods.","Add a startup health check verifying each configured indicator has non-empty parameters.","Use a shared guard helper (e.g., RequireNonEmpty) and call it consistently across all indicator calculators."],"tags":["gpu","argument-validation","indicator-params","ilgpu","gator-oscillator"],"backgroundTag":null,"analyzedSha":"601a191de678bff83da28b14828f8885214ca71c","analyzedAt":"2026-08-13T20:43:24.460Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}