I'm trying to use a custom indicator with an alpha, and no matter how I try to do it it gives me a data mismatch. I've been spinning my wheels for days but there doesn't seem to be much out there.

in the alpha OnSecurityChanged event, I have 

// Initialize data for added securities var symbols = changes.AddedSecurities.Select(x => x.Symbol); algorithm.History(symbols, _numberOfBarsNeededForHistory, _resolution).PushThroughConsolidators(symbol => { SymbolData symbolData; if (!_symbolDataBySymbol.TryGetValue(symbol, out symbolData)) { symbolData = new SymbolData(algorithm, symbol, _consolidatorTimeSpan); _symbolDataBySymbol[symbol] = symbolData; } return symbolData.GetConsolidator(); });

In the SymbolData class

private class SymbolData { private readonly Symbol _symbol; private readonly IDataConsolidator _consolidator; private Tdi _tdiIndicator { get; } public SymbolData(QCAlgorithm algorithm, Symbol symbol, TimeSpan consolidatorResolution) { _symbol = symbol; _tdiIndicator = new Tdi(); _consolidator = algorithm.ResolveConsolidator(symbol, consolidatorResolution); algorithm.RegisterIndicator(symbol, _tdiIndicator, _consolidator); } public bool IsReady { get { return _tdiIndicator.IsReady; } } internal void RemoveConsolidators(QCAlgorithm algorithm) { algorithm.SubscriptionManager.RemoveConsolidator(_symbol, _consolidator); } internal IDataConsolidator GetConsolidator() { return _consolidator; } }

And in the custom indicator class

public class Tdi : BarIndicator, IIndicatorWarmUpPeriodProvider {

and

protected override decimal ComputeNextValue(IBaseDataBar input) {

The error I get when I try to run this is 

System.ArgumentException: IndicatorBase.Update() 'input' expected to be of type QuantConnect.Indicators.IndicatorDataPoint but is of type QuantConnect.Data.Market.TradeBar at QuantConnect.Indicators.IndicatorBase`1[T].Update (QuantConnect.Data.IBaseData input) [0x000aa] in <7096479a1e444df4a9f2ad9c767cb7f0>:0 at QuantConnect.Indicators.Tdi.ComputeNextValue (QuantConnect.Data.Market.IBaseDataBar input) [0x00001] in :0 at QuantConnect.Indicators.IndicatorBase`1[T].ValidateAndComputeNextValue (T input) [0x00000] in <7096479a1e444df4a9f2ad9c767cb7f0>:0 at QuantConnect.Indicators.IndicatorBase`1[T].Update (QuantConnect.Data.IBaseData input) [0x000bc] in <7096479a1e444df4a9f2ad9c767cb7f0>:0 at QuantConnect.Algorithm.QCAlgorithm+<>c__DisplayClass552_0`1[T].b__1 (System.Object sender, QuantConnect.Data.IBaseData consolidated) [0x0000e] in <48c39c54657e4638b08952dba8212e4d>:0 at QuantConnect.Data.Consolidators.DataConsolidator`1[TInput].OnDataConsolidated (QuantConnect.Data.IBaseData consolidated) [0x0000a] in <9974326b8fbc4e48acebad4ed7c9c9e4>:0 at QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase`2[T, TConsolidated].OnDataConsolidated (TConsolidated e) [0x00000] in <9974326b8fbc4e48acebad4ed7c9c9e4>:0 at QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase`2[T, TConsolidated].Update (T data) [0x001e0] in <9974326b8fbc4e48acebad4ed7c9c9e4>:0 at QuantConnect.Data.Consolidators.DataConsolidator`1[TInput].Update (QuantConnect.Data.IBaseData data) [0x00037] in <9974326b8fbc4e48acebad4ed7c9c9e4>:0 at QuantConnect.Data.SliceExtensions+<>c__DisplayClass10_0.b__0 (QuantConnect.Data.BaseData data) [0x0001b] in <9974326b8fbc4e48acebad4ed7c9c9e4>:0 at QuantConnect.Data.SliceExtensions.PushThrough (System.Collections.Generic.IEnumerable`1[T] slices, System.Action`1[T] handler) [0x00095] in <9974326b8fbc4e48acebad4ed7c9c9e4>:0 at QuantConnect.Data.SliceExtensions.PushThroughConsolidators (System.Collections.Generic.IEnumerable`1[T] slices, System.Func`2[T, TResult] consolidatorsProvider) [0x0000d] in <9974326b8fbc4e48acebad4ed7c9c9e4>:0 at QuantConnect.Algorithm.CSharp.Alphas.TDIAlphaModel.OnSecuritiesChanged (QuantConnect.Algorithm.QCAlgorithm algorithm, QuantConnect.Data.UniverseSelection.SecurityChanges changes) [0x000c5] in :0 at QuantConnect.Algorithm.QCAlgorithm.OnFrameworkSecuritiesChanged (QuantConnect.Data.UniverseSelection.SecurityChanges changes) [0x00030] in <48c39c54657e4638b08952dba8212e4d>:0 at QuantConnect.Lean.Engine.AlgorithmManager.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Interfaces.IAlgorithm algorithm, QuantConnect.Lean.Engine.DataFeeds.ISynchronizer synchronizer, QuantConnect.Lean.Engine.TransactionHandlers.ITransactionHandler transactions,

Any help would be very much appreciated.