StockSharp/StockSharp · error · ArgumentOutOfRangeException
LocalizedStrings.InvalidValue
Error message
LocalizedStrings.InvalidValue
What it means
LaguerreRSI.Gamma is the smoothing factor in John Ehlers' Laguerre RSI and must lie strictly inside the open interval (0, 1). Gamma == 0 freezes the filter and Gamma == 1 makes it unstable, so the setter throws ArgumentOutOfRangeException with LocalizedStrings.InvalidValue for value <= 0 or value >= 1. The [Range(0.000001, 0.999999)] attribute mirrors this in UI editors.
Source
Thrown at Algo.Indicators/LaguerreRSI.cs:45
private decimal _gamma;
/// <summary>
/// Gamma parameter.
/// </summary>
[Display(
ResourceType = typeof(LocalizedStrings),
Name = LocalizedStrings.GammaKey,
Description = LocalizedStrings.GammaDescriptionKey,
GroupName = LocalizedStrings.GeneralKey)]
[Range(0.000001, 0.999999)]
public decimal Gamma
{
get => _gamma;
set
{
if (value <= 0 || value >= 1)
throw new ArgumentOutOfRangeException(nameof(value), value, LocalizedStrings.InvalidValue);
if (value == Gamma)
return;
_gamma = value;
Reset();
}
}
/// <inheritdoc />
protected override IIndicatorValue OnProcess(IIndicatorValue input)
{
var price = input.ToDecimal(Source);
var gamma = Gamma;
var gamma1 = 1 - gamma;
var l0 = (1 - gamma) * price + gamma * _l0;View on GitHub (pinned to 601a191de6)
Solutions
- Set Gamma strictly between 0 and 1 (typical 0.5m–0.7m; default 0.5).
- Clamp into the open interval: `lr.Gamma = Math.Clamp(g, 0.000001m, 0.999999m)`.
- Map percentage input correctly: `lr.Gamma = pct / 100m` and reject endpoints.
Example fix
// before lr.Gamma = 1m; // after lr.Gamma = 0.7m;
Defensive patterns
Strategy: validation
Validate before calling
static decimal SanitizeGamma(decimal g) => Math.Clamp(g, 0.000001m, 0.999999m); // usage: lr.Gamma = SanitizeGamma(raw);
Type guard
static bool IsValidGamma(decimal g) => g > 0 && g < 1;
Try / catch
try { lr.Gamma = raw; }
catch (ArgumentOutOfRangeException) { lr.Gamma = 0.5m; } Prevention
- Use the existing [Range(0.000001, 0.999999)] attribute in UI binding.
- Convert percentage input: gamma = pct/100 and reject 0% and 100%.
- Test the inclusive endpoints 0 and 1 explicitly.
When it happens
Trigger: Setting Gamma to exactly 0, exactly 1, or outside the range, e.g. `lr.Gamma = 0`, `lr.Gamma = 1m`, or `lr.Gamma = 1.5m`.
Common situations: Slider/spinner that allows the inclusive endpoints 0 or 1, percentage-style input (0–100) mistakenly fed directly as Gamma, or a deserialized value of 1.
Related errors
- LocalizedStrings.InvalidValue
- LocalizedStrings.InvalidValue
- LocalizedStrings.InvalidValue
- LocalizedStrings.InvalidValue
- LocalizedStrings.InvalidValue
AI-assisted analysis of StockSharp/StockSharp@601a191de6 (2026-08-13).
Data as JSON: /api/errors/ac8dfaaab3ceef2c.
Report an issue: GitHub.