Ejemplo n.º 1
0
        /// <summary>
        /// The Dynamic Momentum Index (DMI) as developed by Tushar Chande and Stanley Kroll and outlined in detail in their book The New Technical Trader.
        /// </summary>
        /// <returns></returns>
        public DMIndex DMIndex(Data.IDataSeries input, int smooth)
        {
            if (cacheDMIndex != null)
            {
                for (int idx = 0; idx < cacheDMIndex.Length; idx++)
                {
                    if (cacheDMIndex[idx].Smooth == smooth && cacheDMIndex[idx].EqualsInput(input))
                    {
                        return(cacheDMIndex[idx]);
                    }
                }
            }

            lock (checkDMIndex)
            {
                checkDMIndex.Smooth = smooth;
                smooth = checkDMIndex.Smooth;

                if (cacheDMIndex != null)
                {
                    for (int idx = 0; idx < cacheDMIndex.Length; idx++)
                    {
                        if (cacheDMIndex[idx].Smooth == smooth && cacheDMIndex[idx].EqualsInput(input))
                        {
                            return(cacheDMIndex[idx]);
                        }
                    }
                }

                DMIndex indicator = new DMIndex();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input  = input;
                indicator.Smooth = smooth;
                Indicators.Add(indicator);
                indicator.SetUp();

                DMIndex[] tmp = new DMIndex[cacheDMIndex == null ? 1 : cacheDMIndex.Length + 1];
                if (cacheDMIndex != null)
                {
                    cacheDMIndex.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheDMIndex        = tmp;
                return(indicator);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The Dynamic Momentum Index (DMI) as developed by Tushar Chande and Stanley Kroll and outlined in detail in their book The New Technical Trader.
        /// </summary>
        /// <returns></returns>
        public DMIndex DMIndex(Data.IDataSeries input, int smooth)
        {
            if (cacheDMIndex != null)
                for (int idx = 0; idx < cacheDMIndex.Length; idx++)
                    if (cacheDMIndex[idx].Smooth == smooth && cacheDMIndex[idx].EqualsInput(input))
                        return cacheDMIndex[idx];

            lock (checkDMIndex)
            {
                checkDMIndex.Smooth = smooth;
                smooth = checkDMIndex.Smooth;

                if (cacheDMIndex != null)
                    for (int idx = 0; idx < cacheDMIndex.Length; idx++)
                        if (cacheDMIndex[idx].Smooth == smooth && cacheDMIndex[idx].EqualsInput(input))
                            return cacheDMIndex[idx];

                DMIndex indicator = new DMIndex();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Smooth = smooth;
                Indicators.Add(indicator);
                indicator.SetUp();

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