Example #1
0
        public void BuildCore(ISessionIndicator sessionIndicator)
        {
            string coreIdentityCode = ADXCore.CreateIdentityCode(periods);

            core = sessionIndicator.CoreIndicators.ContainsKey(coreIdentityCode) ? sessionIndicator.CoreIndicators[coreIdentityCode].IndicatorInstance as ADXCore : null;
            if (core == null)
            {
                string        trueRangeIdentityCode = TrueRangeCore.CreateIdentityCode();
                TrueRangeCore trueRangeCore         = sessionIndicator.CoreIndicators.ContainsKey(trueRangeIdentityCode) ? sessionIndicator.CoreIndicators[trueRangeIdentityCode].IndicatorInstance as TrueRangeCore : null;
                if (trueRangeCore == null)
                {
                    trueRangeCore = TrueRangeCore.CreateInstance(barType);
                    sessionIndicator.CoreIndicators.Add(trueRangeCore.IdentityCode, new CoreIndicator(trueRangeCore));
                }

                string dmIdentityCode          = DirectionalMovementCore.CreateIdentityCode();
                DirectionalMovementCore dmCore = sessionIndicator.CoreIndicators.ContainsKey(dmIdentityCode) ? sessionIndicator.CoreIndicators[dmIdentityCode].IndicatorInstance as DirectionalMovementCore : null;
                if (dmCore == null)
                {
                    dmCore = DirectionalMovementCore.CreateInstance(barType);
                    sessionIndicator.CoreIndicators.Add(dmCore.IdentityCode, new CoreIndicator(dmCore));
                }

                string dxIdentityCode = DirectionalMovementIndexCore.CreateIdentityCode(periods);
                DirectionalMovementIndexCore dxCore = sessionIndicator.CoreIndicators.ContainsKey(dxIdentityCode) ? sessionIndicator.CoreIndicators[dxIdentityCode].IndicatorInstance as DirectionalMovementIndexCore : null;
                if (dxCore == null)
                {
                    dxCore = DirectionalMovementIndexCore.CreateInstance(barType, periods, trueRangeCore, dmCore);
                    sessionIndicator.CoreIndicators.Add(dxCore.IdentityCode, new CoreIndicator(dxCore));
                }

                core = ADXCore.CreateInstance(barType, periods, dxCore, this.OnCalculationCompleted);
                sessionIndicator.CoreIndicators.Add(core.IdentityCode, new CoreIndicator(core));
            }
        }
Example #2
0
        private DirectionalMovementIndexCore(BarItemType barItemType, int periods, TrueRangeCore trueRangeCore, DirectionalMovementCore directionalMovementCore, IndicatorDelegates.CalculationCompletedHandler onCalculationCompleted = null)
            : base(DISPLAY_NAME, SHORT_NAME, DESCRIPTION, barItemType)
        {
            this.barCount    = periods;
            this.maxBarIndex = barCount - 1;

            this.AddDependency(barItemType, directionalMovementCore);
            this.AddDependency(barItemType, trueRangeCore);

            this.directionalMovement = directionalMovementCore;
            this.trueRange           = trueRangeCore;

            this.identityCode = CreateIdentityCode(periods);

            if (onCalculationCompleted != null)
            {
                this.Calculated += onCalculationCompleted;
            }
        }
Example #3
0
 public static DirectionalMovementIndexCore CreateInstance(BarItemType barItemType, int periods, TrueRangeCore trueRangeCore, DirectionalMovementCore directionalMovementCore, IndicatorDelegates.CalculationCompletedHandler onCalculationCompleted = null)
 {
     return(new DirectionalMovementIndexCore(barItemType, periods, trueRangeCore, directionalMovementCore, onCalculationCompleted));
 }