{"record":{"id":"e0586f7c5df99b67","repo":"StockSharp/StockSharp","slug":"indicator-cannot-be-composite-e0586f","errorCode":null,"errorMessage":"Indicator cannot be composite.","messagePattern":"Indicator cannot be composite\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Algo.Strategies/Strategy_HighLevelSubscriptions.cs","lineNumber":593,"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":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/StockSharp/StockSharp/blob/601a191de678bff83da28b14828f8885214ca71c/Algo.Strategies/Strategy_HighLevelSubscriptions.cs#L575-L611","documentation":"Thrown by ValidateIndicators when an indicator argument implements IComplexIndicator (line 592-593). The scalar Bind/BindWithEmpty overloads extract exactly one decimal per indicator via indicator.Source, which is meaningless for a composite that emits several values (e.g. Bollinger Bands: UpBand/LowBand/MovingAverage), so composites are explicitly rejected with 'Indicator cannot be composite.'","triggerScenarios":"Passing any BaseComplexIndicator subclass directly into a positional Bind/BindWithEmpty: BollingerBands, StochasticOscillator, Ichimoku, Alligator, KeltnerChannels, DonchianChannels, Envelope, AverageDirectionalIndex, and ~30 others.","commonSituations":"Treating a composite indicator like a single-value indicator; assuming the fluent binder will pick a default band; upgrading a strategy from a single SMA to Bollinger Bands without switching to BindEx.","solutions":["Bind one of the composite's inner child indicators instead (e.g. bb.UpBand, bb.LowBand, or bb.MovingAverage), which are themselves non-composite IIndicator.","Use BindEx(IIndicator, Action<T, IIndicatorValue>, bool) to receive the full IIndicatorValue and read whichever output you need.","For multiple child outputs at once, use BindEx(IIndicator[], ...) and downcast each IIndicatorValue to the composite's typed value interface."],"exampleFix":"// before\nvar bb = new BollingerBands();\nhandler.Bind(bb, (c, v) => OnPrice(c, v)); // ArgumentException: Indicator cannot be composite.\n\n// after - bind a single inner band\nhandler.Bind(bb.UpBand, (c, v) => OnPrice(c, v));\n\n// or read full composite value via BindEx\nhandler.BindEx(bb, (c, iv) => {\n    var bv = (IBollingerBandsValue)iv;\n    OnBands(c, bv.UpBand, bv.LowBand, bv.MovingAverage);\n}, allowEmpty: true);","handlingStrategy":"type-guard","validationCode":"// Reject composites before calling a scalar Bind overload.\nstatic void EnsureScalar(params IIndicator[] inds)\n{\n    foreach (var i in inds)\n        if (i is IComplexIndicator)\n            throw new InvalidOperationException($\"{i?.GetType().Name} is composite; bind an inner child or use BindEx.\");\n}\n\nEnsureScalar(ind1, ind2);\nhandler.Bind(ind1, ind2, cb);","typeGuard":"static bool IsScalarIndicator(IIndicator i)\n    => i is not null && i is not IComplexIndicator;","tryCatchPattern":null,"preventionTips":["Know which indicators are composite: BollingerBands, StochasticOscillator, Ichimoku, Alligator, Envelope, Keltner/Donchian/Price channels, ADX/DMI, MACD-histogram variants, etc.","For a composite, bind its inner child indicator (e.g. bb.UpBand) or use BindEx to receive the full IIndicatorValue.","Filter dynamically-built indicator lists to exclude IComplexIndicator before passing them to a scalar Bind."],"tags":["stocksharp","bind","indicator","composite","icomplexindicator","argumentexception"],"backgroundTag":null,"analyzedSha":"601a191de678bff83da28b14828f8885214ca71c","analyzedAt":"2026-08-13T20:43:24.460Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}