{"record":{"id":"e63cc6017f2bc29f","repo":"QuantConnect/Lean","slug":"customnotinherit-indicator-was-expected-to-have-p","errorCode":null,"errorMessage":"_customNotInherit indicator was expected to have processed 60 datapoints already","messagePattern":"_customNotInherit indicator was expected to have processed 60 datapoints already","errorType":"exception","errorClass":"RegressionTestException","httpStatus":null,"severity":"error","filePath":"Algorithm.CSharp/CustomWarmUpPeriodIndicatorAlgorithm.cs","lineNumber":87,"sourceCode":"            // Try to warm up _customNotWarmUp indicator. It's expected from LEAN to skip the warm up process\n            // because this indicator doesn't implement IIndicatorWarmUpPeriodProvider\n            WarmUpIndicator(\"SPY\", _customNotWarmUp, Resolution.Minute);\n\n            // Check _customNotWarmUp indicator is not ready, because the warm up process was skipped\n            if (_customNotWarmUp.IsReady)\n            {\n                throw new RegressionTestException(\"_customNotWarmUp indicator wasn't expected to be warmed up\");\n            }\n\n            WarmUpIndicator(\"SPY\", _customNotInherit, Resolution.Minute);\n            // Check _customWarmUp indicator has already been warmed up with the requested data\n            if (!_customNotInherit.IsReady)\n            {\n                throw new RegressionTestException(\"_customNotInherit indicator was expected to be ready\");\n            }\n            if (_customNotInherit.Samples != 60)\n            {\n                throw new RegressionTestException(\"_customNotInherit indicator was expected to have processed 60 datapoints already\");\n            }\n\n            WarmUpIndicator(\"SPY\", _duplicateSMA, Resolution.Minute);\n            // Check _customWarmUp indicator has already been warmed up with the requested data\n            if (!_duplicateSMA.IsReady)\n            {\n                throw new RegressionTestException(\"_duplicateSMA indicator was expected to be ready\");\n            }\n            if (_duplicateSMA.Samples != 60)\n            {\n                throw new RegressionTestException(\"_duplicateSMA indicator was expected to have processed 60 datapoints already\");\n            }\n        }\n\n        public override void OnData(Slice slice)\n        {\n            if (!Portfolio.Invested)\n            {","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.CSharp/CustomWarmUpPeriodIndicatorAlgorithm.cs#L69-L105","documentation":"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.","triggerScenarios":"_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.","commonSituations":"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.","solutions":["Log _customNotInherit.Samples to determine if above or below 60.","If below: verify 60+ minute bars exist before SetStartDate in the history data.","If above: check for double-feeding (RegisterIndicator + WarmUpIndicator both feeding), or off-by-one in history bar count.","If testing engine changes, verify History() call in warm-up requests exactly WarmUpPeriod bars."],"exampleFix":"// before — warm-up and registration both feed the indicator, doubling samples\nRegisterIndicator(\"SPY\", _customNotInherit, Resolution.Minute); // feeds live data\nWarmUpIndicator(\"SPY\", _customNotInherit, Resolution.Minute);  // feeds history\n// OnData feeds again -> Samples > 60 at warm-up time is impossible, but if history\n// returns 61 bars, Samples == 61\n\n// after — ensure history fetch is exact\n// In WarmUpIndicator implementation:\nvar bars = History<IBaseData>(symbol, indicator.WarmUpPeriod, resolution).ToList();\nDebug.Assert(bars.Count == indicator.WarmUpPeriod, $\"Expected {indicator.WarmUpPeriod} bars, got {bars.Count}\");","handlingStrategy":"validation","validationCode":"// Validate sample count for built-in SMA\nWarmUpIndicator(\"SPY\", _customNotInherit, Resolution.Minute);\nif (_customNotInherit.Samples != 60)\n    Log($\"SMA sample count mismatch: {_customNotInherit.Samples}, expected 60\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't feed the indicator manually or via RegisterIndicator before WarmUpIndicator — it adds samples.","Verify history data has exactly the right number of bars; insufficient data yields fewer samples.","Check for off-by-one errors in warm-up history retrieval when modifying the engine."],"tags":["quantconnect","lean","indicator","sma","warmup","samples","history","regression-test"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}