public SymbolData( Security security, int fastPeriod, int slowPeriod, QCAlgorithm algorithm, Resolution resolution) { _algorithm = algorithm; _security = security; _fastConsolidator = algorithm.ResolveConsolidator(security.Symbol, resolution); _slowConsolidator = algorithm.ResolveConsolidator(security.Symbol, resolution); algorithm.SubscriptionManager.AddConsolidator(security.Symbol, _fastConsolidator); algorithm.SubscriptionManager.AddConsolidator(security.Symbol, _slowConsolidator); // create fast/slow EMAs _fast = new ExponentialMovingAverage(security.Symbol, fastPeriod, ExponentialMovingAverage.SmoothingFactorDefault(fastPeriod)); _slow = new ExponentialMovingAverage(security.Symbol, slowPeriod, ExponentialMovingAverage.SmoothingFactorDefault(slowPeriod)); algorithm.RegisterIndicator(security.Symbol, _fast, _fastConsolidator); algorithm.RegisterIndicator(security.Symbol, _slow, _slowConsolidator); algorithm.WarmUpIndicator(security.Symbol, _fast, resolution); algorithm.WarmUpIndicator(security.Symbol, _slow, resolution); }
/// <summary>Initializes a new instance of the ExponentialMovingAverage class with the specified name and period /// </summary> /// <param name="name">The name of this indicator</param> /// <param name="period">The period of the EMA</param> public ExponentialMovingAverage(string name, int period) : base(name) { _period = period; _k = ExponentialMovingAverage.SmoothingFactorDefault(period); }