Ejemplo n.º 1
0
        /// <summary>
        /// The Directional Movement Index is quite similiar to Welles Wilder's Relative Strength Index. The difference is the DMI uses variable time periods (from 3 to 30) vs. the RSI's fixed periods.
        /// </summary>
        /// <returns></returns>
        public DMI DMI(Data.IDataSeries input, int period)
        {
            if (cacheDMI != null)
            {
                for (int idx = 0; idx < cacheDMI.Length; idx++)
                {
                    if (cacheDMI[idx].Period == period && cacheDMI[idx].EqualsInput(input))
                    {
                        return(cacheDMI[idx]);
                    }
                }
            }

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

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

                DMI indicator = new DMI();
                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();

                DMI[] tmp = new DMI[cacheDMI == null ? 1 : cacheDMI.Length + 1];
                if (cacheDMI != null)
                {
                    cacheDMI.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheDMI            = tmp;
                return(indicator);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The Directional Movement Index is quite similiar to Welles Wilder's Relative Strength Index. The difference is the DMI uses variable time periods (from 3 to 30) vs. the RSI's fixed periods.
        /// </summary>
        /// <returns></returns>
        public DMI DMI(Data.IDataSeries input, int period)
        {
            if (cacheDMI != null)
                for (int idx = 0; idx < cacheDMI.Length; idx++)
                    if (cacheDMI[idx].Period == period && cacheDMI[idx].EqualsInput(input))
                        return cacheDMI[idx];

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

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

                DMI indicator = new DMI();
                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();

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