QuantConnect/Lean · error · RegressionTestException

_customNotInherit indicator was expected to have processed 6

Error message

_customNotInherit indicator was expected to have processed 60 datapoints already

What it means

This RegressionTestException is thrown in Initialize after confirming _customNotInherit (SimpleMovingAverage) IsReady. It asserts _customNotInherit.Samples == 60, verifying the built-in SMA received exactly 60 data points during warm-up. LEAN throws it because the warm-up process must feed precisely WarmUpPeriod bars — more or fewer indicates a counting or history-retrieval bug.

Source

Thrown at Algorithm.CSharp/CustomWarmUpPeriodIndicatorAlgorithm.cs:87

            // Try to warm up _customNotWarmUp indicator. It's expected from LEAN to skip the warm up process
            // because this indicator doesn't implement IIndicatorWarmUpPeriodProvider
            WarmUpIndicator("SPY", _customNotWarmUp, Resolution.Minute);

            // Check _customNotWarmUp indicator is not ready, because the warm up process was skipped
            if (_customNotWarmUp.IsReady)
            {
                throw new RegressionTestException("_customNotWarmUp indicator wasn't expected to be warmed up");
            }

            WarmUpIndicator("SPY", _customNotInherit, Resolution.Minute);
            // Check _customWarmUp indicator has already been warmed up with the requested data
            if (!_customNotInherit.IsReady)
            {
                throw new RegressionTestException("_customNotInherit indicator was expected to be ready");
            }
            if (_customNotInherit.Samples != 60)
            {
                throw new RegressionTestException("_customNotInherit indicator was expected to have processed 60 datapoints already");
            }

            WarmUpIndicator("SPY", _duplicateSMA, Resolution.Minute);
            // Check _customWarmUp indicator has already been warmed up with the requested data
            if (!_duplicateSMA.IsReady)
            {
                throw new RegressionTestException("_duplicateSMA indicator was expected to be ready");
            }
            if (_duplicateSMA.Samples != 60)
            {
                throw new RegressionTestException("_duplicateSMA indicator was expected to have processed 60 datapoints already");
            }
        }

        public override void OnData(Slice slice)
        {
            if (!Portfolio.Invested)
            {

View on GitHub (pinned to d2c3659f87)

Solutions

  1. Log _customNotInherit.Samples to determine if above or below 60.
  2. If below: verify 60+ minute bars exist before SetStartDate in the history data.
  3. If above: check for double-feeding (RegisterIndicator + WarmUpIndicator both feeding), or off-by-one in history bar count.
  4. If testing engine changes, verify History() call in warm-up requests exactly WarmUpPeriod bars.

Example fix

// before — warm-up and registration both feed the indicator, doubling samples
RegisterIndicator("SPY", _customNotInherit, Resolution.Minute); // feeds live data
WarmUpIndicator("SPY", _customNotInherit, Resolution.Minute);  // feeds history
// OnData feeds again -> Samples > 60 at warm-up time is impossible, but if history
// returns 61 bars, Samples == 61

// after — ensure history fetch is exact
// In WarmUpIndicator implementation:
var bars = History<IBaseData>(symbol, indicator.WarmUpPeriod, resolution).ToList();
Debug.Assert(bars.Count == indicator.WarmUpPeriod, $"Expected {indicator.WarmUpPeriod} bars, got {bars.Count}");
Defensive patterns

Strategy: validation

Validate before calling

// Validate sample count for built-in SMA
WarmUpIndicator("SPY", _customNotInherit, Resolution.Minute);
if (_customNotInherit.Samples != 60)
    Log($"SMA sample count mismatch: {_customNotInherit.Samples}, expected 60");

Prevention

When it happens

Trigger: _customNotInherit.Samples != 60 after WarmUpIndicator. If Samples > 60, the SMA was fed extra bars (off-by-one in history retrieval or pre-existing samples). If Samples < 60, the history provider returned fewer bars than the warm-up period requires.

Common situations: Minute history data insufficient before StartDate, warm-up history retrieval off-by-one, or a LEAN version change to the history-count calculation that returns WarmUpPeriod + 1 or WarmUpPeriod - 1 bars.

Related errors


AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13). Data as JSON: /api/errors/e63cc6017f2bc29f. Report an issue: GitHub.