Example #1
0
        /// <summary>
        /// The Ease of Movement (EMV) indicator emphasizes days in which the stock is moving easily and minimizes the days in which the stock is finding it difficult to move. A buy signal is generated when the EMV crosses above zero, a sell signal when it crosses below zero. When the EMV hovers around zero, then there are small price movements and/or high volume, which is to say, the price is not moving easily.
        /// </summary>
        /// <returns></returns>
        public EaseOfMovement EaseOfMovement(Data.IDataSeries input, int smoothing, int volumeDivisor)
        {
            if (cacheEaseOfMovement != null)
            {
                for (int idx = 0; idx < cacheEaseOfMovement.Length; idx++)
                {
                    if (cacheEaseOfMovement[idx].Smoothing == smoothing && cacheEaseOfMovement[idx].VolumeDivisor == volumeDivisor && cacheEaseOfMovement[idx].EqualsInput(input))
                    {
                        return(cacheEaseOfMovement[idx]);
                    }
                }
            }

            lock (checkEaseOfMovement)
            {
                checkEaseOfMovement.Smoothing = smoothing;
                smoothing = checkEaseOfMovement.Smoothing;
                checkEaseOfMovement.VolumeDivisor = volumeDivisor;
                volumeDivisor = checkEaseOfMovement.VolumeDivisor;

                if (cacheEaseOfMovement != null)
                {
                    for (int idx = 0; idx < cacheEaseOfMovement.Length; idx++)
                    {
                        if (cacheEaseOfMovement[idx].Smoothing == smoothing && cacheEaseOfMovement[idx].VolumeDivisor == volumeDivisor && cacheEaseOfMovement[idx].EqualsInput(input))
                        {
                            return(cacheEaseOfMovement[idx]);
                        }
                    }
                }

                EaseOfMovement indicator = new EaseOfMovement();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input         = input;
                indicator.Smoothing     = smoothing;
                indicator.VolumeDivisor = volumeDivisor;
                Indicators.Add(indicator);
                indicator.SetUp();

                EaseOfMovement[] tmp = new EaseOfMovement[cacheEaseOfMovement == null ? 1 : cacheEaseOfMovement.Length + 1];
                if (cacheEaseOfMovement != null)
                {
                    cacheEaseOfMovement.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheEaseOfMovement = tmp;
                return(indicator);
            }
        }
        /// <summary>
        /// The Ease of Movement (EMV) indicator emphasizes days in which the stock is moving easily and minimizes the days in which the stock is finding it difficult to move. A buy signal is generated when the EMV crosses above zero, a sell signal when it crosses below zero. When the EMV hovers around zero, then there are small price movements and/or high volume, which is to say, the price is not moving easily.
        /// </summary>
        /// <returns></returns>
        public EaseOfMovement EaseOfMovement(Data.IDataSeries input, int smoothing, int volumeDivisor)
        {
            if (cacheEaseOfMovement != null)
                for (int idx = 0; idx < cacheEaseOfMovement.Length; idx++)
                    if (cacheEaseOfMovement[idx].Smoothing == smoothing && cacheEaseOfMovement[idx].VolumeDivisor == volumeDivisor && cacheEaseOfMovement[idx].EqualsInput(input))
                        return cacheEaseOfMovement[idx];

            lock (checkEaseOfMovement)
            {
                checkEaseOfMovement.Smoothing = smoothing;
                smoothing = checkEaseOfMovement.Smoothing;
                checkEaseOfMovement.VolumeDivisor = volumeDivisor;
                volumeDivisor = checkEaseOfMovement.VolumeDivisor;

                if (cacheEaseOfMovement != null)
                    for (int idx = 0; idx < cacheEaseOfMovement.Length; idx++)
                        if (cacheEaseOfMovement[idx].Smoothing == smoothing && cacheEaseOfMovement[idx].VolumeDivisor == volumeDivisor && cacheEaseOfMovement[idx].EqualsInput(input))
                            return cacheEaseOfMovement[idx];

                EaseOfMovement indicator = new EaseOfMovement();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Smoothing = smoothing;
                indicator.VolumeDivisor = volumeDivisor;
                Indicators.Add(indicator);
                indicator.SetUp();

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