Beispiel #1
0
        public void BuildCore(ISessionIndicator sessionIndicator)
        {
            string coreIdentityCode = MACDCore.CreateIdentityCode(fastEMAPeriod, slowEMAPeriod, signalLinePeriod);

            core = sessionIndicator.CoreIndicators.ContainsKey(coreIdentityCode) ? sessionIndicator.CoreIndicators[coreIdentityCode].IndicatorInstance as MACDCore : null;
            if (core == null)
            {
                string  fastEMAIdentityCode = EMACore.CreateIdentityCode(fastEMAPeriod);
                EMACore fastEMACore         = sessionIndicator.CoreIndicators.ContainsKey(fastEMAIdentityCode) ? sessionIndicator.CoreIndicators[fastEMAIdentityCode].IndicatorInstance as EMACore : null;
                if (fastEMACore == null)
                {
                    fastEMACore = EMACore.CreateInstance(barType, fastEMAPeriod);
                    sessionIndicator.CoreIndicators.Add(fastEMACore.IdentityCode, new CoreIndicator(fastEMACore));
                }

                string  slowEMAIdentityCode = EMACore.CreateIdentityCode(slowEMAPeriod);
                EMACore slowEMACore         = sessionIndicator.CoreIndicators.ContainsKey(slowEMAIdentityCode) ? sessionIndicator.CoreIndicators[slowEMAIdentityCode].IndicatorInstance as EMACore : null;
                if (slowEMACore == null)
                {
                    slowEMACore = EMACore.CreateInstance(barType, slowEMAPeriod);
                    sessionIndicator.CoreIndicators.Add(slowEMACore.IdentityCode, new CoreIndicator(slowEMACore));
                }

                core = MACDCore.CreateInstance(barType, fastEMACore, slowEMACore, signalLinePeriod, this.OnCalculationCompleted);
                sessionIndicator.CoreIndicators.Add(core.IdentityCode, new CoreIndicator(core));
            }
        }
Beispiel #2
0
        private MACDCore(BarItemType barItemType, EMACore fastEMACore, EMACore slowEMACore, int signalLinePeriod, IndicatorDelegates.CalculationCompletedHandler onCalculationCompleted = null)
            : base(DISPLAY_NAME, SHORT_NAME, DESCRIPTION, barItemType)
        {
            this.barCount                    = slowEMACore.Period;
            this.maxBarIndex                 = barCount - 1;
            this.signalLinePeriod            = signalLinePeriod;
            this.signalLineSmoothingConstant = (double)2 / (signalLinePeriod + 1);

            this.AddDependency(barItemType, fastEMACore);
            this.AddDependency(barItemType, slowEMACore);

            this.fastEMA = fastEMACore;
            this.slowEMA = slowEMACore;

            this.identityCode = CreateIdentityCode(fastEMA.Period, slowEMA.Period, signalLinePeriod);

            if (onCalculationCompleted != null)
            {
                this.Calculated += onCalculationCompleted;
            }
        }
Beispiel #3
0
 public static MACDCore CreateInstance(BarItemType barItemType, EMACore fastEMACore, EMACore slowEMACore, int signalLinePeriod, IndicatorDelegates.CalculationCompletedHandler onCalculationCompleted = null)
 {
     return(new MACDCore(barItemType, fastEMACore, slowEMACore, signalLinePeriod, onCalculationCompleted));
 }