コード例 #1
0
        /// <summary>
        /// The Volume Oscillator measures volume by calculating the difference of a fast and a slow moving average of volume. The Volume Oscillator can provide insight into the strength or weakness of a price trend. A positive value suggests there is enough market support to continue driving price activity in the direction of the current trend. A negative value suggests there is a lack of support, that prices may begin to become stagnant or reverse.
        /// </summary>
        /// <returns></returns>
        public VolumeOscillator VolumeOscillator(Data.IDataSeries input, int fast, int slow)
        {
            if (cacheVolumeOscillator != null)
            {
                for (int idx = 0; idx < cacheVolumeOscillator.Length; idx++)
                {
                    if (cacheVolumeOscillator[idx].Fast == fast && cacheVolumeOscillator[idx].Slow == slow && cacheVolumeOscillator[idx].EqualsInput(input))
                    {
                        return(cacheVolumeOscillator[idx]);
                    }
                }
            }

            lock (checkVolumeOscillator)
            {
                checkVolumeOscillator.Fast = fast;
                fast = checkVolumeOscillator.Fast;
                checkVolumeOscillator.Slow = slow;
                slow = checkVolumeOscillator.Slow;

                if (cacheVolumeOscillator != null)
                {
                    for (int idx = 0; idx < cacheVolumeOscillator.Length; idx++)
                    {
                        if (cacheVolumeOscillator[idx].Fast == fast && cacheVolumeOscillator[idx].Slow == slow && cacheVolumeOscillator[idx].EqualsInput(input))
                        {
                            return(cacheVolumeOscillator[idx]);
                        }
                    }
                }

                VolumeOscillator indicator = new VolumeOscillator();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Fast  = fast;
                indicator.Slow  = slow;
                Indicators.Add(indicator);
                indicator.SetUp();

                VolumeOscillator[] tmp = new VolumeOscillator[cacheVolumeOscillator == null ? 1 : cacheVolumeOscillator.Length + 1];
                if (cacheVolumeOscillator != null)
                {
                    cacheVolumeOscillator.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]   = indicator;
                cacheVolumeOscillator = tmp;
                return(indicator);
            }
        }
コード例 #2
0
        /// <summary>
        /// The Volume Oscillator measures volume by calculating the difference of a fast and a slow moving average of volume. The Volume Oscillator can provide insight into the strength or weakness of a price trend. A positive value suggests there is enough market support to continue driving price activity in the direction of the current trend. A negative value suggests there is a lack of support, that prices may begin to become stagnant or reverse.
        /// </summary>
        /// <returns></returns>
        public VolumeOscillator VolumeOscillator(Data.IDataSeries input, int fast, int slow)
        {
            if (cacheVolumeOscillator != null)
                for (int idx = 0; idx < cacheVolumeOscillator.Length; idx++)
                    if (cacheVolumeOscillator[idx].Fast == fast && cacheVolumeOscillator[idx].Slow == slow && cacheVolumeOscillator[idx].EqualsInput(input))
                        return cacheVolumeOscillator[idx];

            lock (checkVolumeOscillator)
            {
                checkVolumeOscillator.Fast = fast;
                fast = checkVolumeOscillator.Fast;
                checkVolumeOscillator.Slow = slow;
                slow = checkVolumeOscillator.Slow;

                if (cacheVolumeOscillator != null)
                    for (int idx = 0; idx < cacheVolumeOscillator.Length; idx++)
                        if (cacheVolumeOscillator[idx].Fast == fast && cacheVolumeOscillator[idx].Slow == slow && cacheVolumeOscillator[idx].EqualsInput(input))
                            return cacheVolumeOscillator[idx];

                VolumeOscillator indicator = new VolumeOscillator();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Fast = fast;
                indicator.Slow = slow;
                Indicators.Add(indicator);
                indicator.SetUp();

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