{"record":{"id":"c6a2c29a5ce649e3","repo":"StockSharp/StockSharp","slug":"indicator-cannot-be-composite","errorCode":null,"errorMessage":"Indicator cannot be composite.","messagePattern":"Indicator cannot be composite\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Algo.Strategies/Legacy/StrategyOld_HighLevel.cs","lineNumber":662,"sourceCode":"\t\t\t\tiv1.ToDecimal(indicator1.Source),\n\t\t\t\tiv2.ToDecimal(indicator2.Source),\n\t\t\t\tiv3.ToDecimal(indicator3.Source),\n\t\t\t\tiv4.ToDecimal(indicator4.Source),\n\t\t\t\tiv5.ToDecimal(indicator5.Source),\n\t\t\t\tiv6.ToDecimal(indicator6.Source),\n\t\t\t\tiv7.ToDecimal(indicator7.Source),\n\t\t\t\tiv8.ToDecimal(indicator8.Source)), false);\n\t\t}\n\n\t\tprivate static void ValidateIndicators(params IIndicator[] indicators)\n\t\t{\n\t\t\tforeach (var ind in indicators)\n\t\t\t{\n\t\t\t\tif (ind is null)\n\t\t\t\t\tthrow new ArgumentNullException(nameof(indicators));\n\n\t\t\t\tif (ind is IComplexIndicator)\n\t\t\t\t\tthrow new ArgumentException(LocalizedStrings.IndicatorNotComposite, nameof(indicators));\n\t\t\t}\n\t\t}\n\n\t\tpublic ISubscriptionHandler<T> Bind(IIndicator[] indicators, Action<T, decimal[]> callback)\n\t\t{\n\t\t\tif (callback is null)\n\t\t\t\tthrow new ArgumentNullException(nameof(callback));\n\n\t\t\tif (indicators is null)\n\t\t\t\tthrow new ArgumentNullException(nameof(indicators));\n\n\t\t\tif (indicators.Any(i => i is IComplexIndicator))\n\t\t\t\tthrow new ArgumentException(LocalizedStrings.IndicatorNotComposite, nameof(indicators));\n\n\t\t\treturn BindEx(indicators, (v, ivs) => callback(v, [.. ivs.Select((val, idx) => val.ToDecimal(indicators[idx].Source))]), false);\n\t\t}\n\n\t\tpublic ISubscriptionHandler<T> BindWithEmpty(IIndicator[] indicators, Action<T, decimal?[]> callback)","sourceCodeStart":644,"sourceCodeEnd":680,"githubUrl":"https://github.com/StockSharp/StockSharp/blob/601a191de678bff83da28b14828f8885214ca71c/Algo.Strategies/Legacy/StrategyOld_HighLevel.cs#L644-L680","documentation":"ValidateIndicators() is called by the multi-indicator Bind overloads (2 through 8 indicators). It rejects any indicator that implements IComplexIndicator (a composite indicator with multiple result outputs) because the decimal extraction logic val.ToDecimal(indicator.Source) assumes a single-result indicator. Composite indicators produce multiple result values that cannot be mapped to a single decimal, so binding them through this path would produce incorrect data.","triggerScenarios":"Passing a composite indicator (e.g., one implementing IComplexIndicator like Macd or any multi-output indicator) to a Bind overload that calls ValidateIndicators.","commonSituations":"Using a MACD, Band, or other multi-output indicator in a multi-indicator Bind call. Refactoring a single-output indicator into a composite without updating the binding code. Misidentifying an indicator as simple when it actually implements IComplexIndicator.","solutions":["Replace composite indicators with their individual simple sub-indicators (e.g., use the MACD's SignalLine or Histogram component directly rather than the MACD container).","For composite indicators, use BindEx with IIndicatorValue[] callbacks instead of Bind with decimal[] callbacks, which handles multi-output values.","Check indicator is not IComplexIndicator before passing to Bind overloads that validate."],"exampleFix":"// before\nhandler.Bind(new[] { sma, macd }, (msg, vals) => { ... });\n// macd is IComplexIndicator -> throws\n\n// after\nhandler.Bind(new[] { sma, macd.SignalLine }, (msg, vals) => { ... });\n// or use BindEx:\nhandler.BindEx(new[] { sma, macd }, (msg, ivs) => { ... }, false);","handlingStrategy":"validation","validationCode":"foreach (var ind in indicators)\n{\n    if (ind is IComplexIndicator)\n        throw new InvalidOperationException($\"{ind.GetType().Name} is composite; use BindEx or sub-indicators.\");\n}","typeGuard":"static bool IsSimpleIndicator(IIndicator ind) => ind is not IComplexIndicator;","tryCatchPattern":null,"preventionTips":["Check for IComplexIndicator before passing indicators to multi-indicator Bind overloads.","Use sub-indicator components (e.g., macd.SignalLine) instead of the composite container.","Fall back to BindEx with IIndicatorValue[] callbacks when composites are needed."],"tags":["strategy","indicator","argument-validation","composite-indicator"],"backgroundTag":null,"analyzedSha":"601a191de678bff83da28b14828f8885214ca71c","analyzedAt":"2026-08-13T20:43:24.460Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}