コード例 #1
0
        /// <summary>
        /// Displays the volume count of a bar.
        /// </summary>
        /// <returns></returns>
        public VolumeCounter VolumeCounter(Data.IDataSeries input, bool countDown, bool showPercent)
        {
            if (cacheVolumeCounter != null)
            {
                for (int idx = 0; idx < cacheVolumeCounter.Length; idx++)
                {
                    if (cacheVolumeCounter[idx].CountDown == countDown && cacheVolumeCounter[idx].ShowPercent == showPercent && cacheVolumeCounter[idx].EqualsInput(input))
                    {
                        return(cacheVolumeCounter[idx]);
                    }
                }
            }

            lock (checkVolumeCounter)
            {
                checkVolumeCounter.CountDown = countDown;
                countDown = checkVolumeCounter.CountDown;
                checkVolumeCounter.ShowPercent = showPercent;
                showPercent = checkVolumeCounter.ShowPercent;

                if (cacheVolumeCounter != null)
                {
                    for (int idx = 0; idx < cacheVolumeCounter.Length; idx++)
                    {
                        if (cacheVolumeCounter[idx].CountDown == countDown && cacheVolumeCounter[idx].ShowPercent == showPercent && cacheVolumeCounter[idx].EqualsInput(input))
                        {
                            return(cacheVolumeCounter[idx]);
                        }
                    }
                }

                VolumeCounter indicator = new VolumeCounter();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input       = input;
                indicator.CountDown   = countDown;
                indicator.ShowPercent = showPercent;
                Indicators.Add(indicator);
                indicator.SetUp();

                VolumeCounter[] tmp = new VolumeCounter[cacheVolumeCounter == null ? 1 : cacheVolumeCounter.Length + 1];
                if (cacheVolumeCounter != null)
                {
                    cacheVolumeCounter.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheVolumeCounter  = tmp;
                return(indicator);
            }
        }
コード例 #2
0
        /// <summary>
        /// Displays the volume count of a bar.
        /// </summary>
        /// <returns></returns>
        public VolumeCounter VolumeCounter(Data.IDataSeries input, bool countDown, bool showPercent)
        {
            if (cacheVolumeCounter != null)
                for (int idx = 0; idx < cacheVolumeCounter.Length; idx++)
                    if (cacheVolumeCounter[idx].CountDown == countDown && cacheVolumeCounter[idx].ShowPercent == showPercent && cacheVolumeCounter[idx].EqualsInput(input))
                        return cacheVolumeCounter[idx];

            lock (checkVolumeCounter)
            {
                checkVolumeCounter.CountDown = countDown;
                countDown = checkVolumeCounter.CountDown;
                checkVolumeCounter.ShowPercent = showPercent;
                showPercent = checkVolumeCounter.ShowPercent;

                if (cacheVolumeCounter != null)
                    for (int idx = 0; idx < cacheVolumeCounter.Length; idx++)
                        if (cacheVolumeCounter[idx].CountDown == countDown && cacheVolumeCounter[idx].ShowPercent == showPercent && cacheVolumeCounter[idx].EqualsInput(input))
                            return cacheVolumeCounter[idx];

                VolumeCounter indicator = new VolumeCounter();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.CountDown = countDown;
                indicator.ShowPercent = showPercent;
                Indicators.Add(indicator);
                indicator.SetUp();

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