Пример #1
0
        /// <summary>
        /// This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside.
        /// </summary>
        /// <returns></returns>
        public DM DM(Data.IDataSeries input, int period)
        {
            if (cacheDM != null)
            {
                for (int idx = 0; idx < cacheDM.Length; idx++)
                {
                    if (cacheDM[idx].Period == period && cacheDM[idx].EqualsInput(input))
                    {
                        return(cacheDM[idx]);
                    }
                }
            }

            lock (checkDM)
            {
                checkDM.Period = period;
                period         = checkDM.Period;

                if (cacheDM != null)
                {
                    for (int idx = 0; idx < cacheDM.Length; idx++)
                    {
                        if (cacheDM[idx].Period == period && cacheDM[idx].EqualsInput(input))
                        {
                            return(cacheDM[idx]);
                        }
                    }
                }

                DM indicator = new DM();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input  = input;
                indicator.Period = period;
                Indicators.Add(indicator);
                indicator.SetUp();

                DM[] tmp = new DM[cacheDM == null ? 1 : cacheDM.Length + 1];
                if (cacheDM != null)
                {
                    cacheDM.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheDM             = tmp;
                return(indicator);
            }
        }
Пример #2
0
        /// <summary>
        /// This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside.
        /// </summary>
        /// <returns></returns>
        public DM DM(Data.IDataSeries input, int period)
        {
            if (cacheDM != null)
                for (int idx = 0; idx < cacheDM.Length; idx++)
                    if (cacheDM[idx].Period == period && cacheDM[idx].EqualsInput(input))
                        return cacheDM[idx];

            lock (checkDM)
            {
                checkDM.Period = period;
                period = checkDM.Period;

                if (cacheDM != null)
                    for (int idx = 0; idx < cacheDM.Length; idx++)
                        if (cacheDM[idx].Period == period && cacheDM[idx].EqualsInput(input))
                            return cacheDM[idx];

                DM indicator = new DM();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Period = period;
                Indicators.Add(indicator);
                indicator.SetUp();

                DM[] tmp = new DM[cacheDM == null ? 1 : cacheDM.Length + 1];
                if (cacheDM != null)
                    cacheDM.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheDM = tmp;
                return indicator;
            }
        }