Пример #1
0
        /// <summary>
        /// Displays the tick count of a bar.
        /// </summary>
        /// <returns></returns>
        public TickCounter TickCounter(Data.IDataSeries input, bool countDown, bool showPercent)
        {
            if (cacheTickCounter != null)
            {
                for (int idx = 0; idx < cacheTickCounter.Length; idx++)
                {
                    if (cacheTickCounter[idx].CountDown == countDown && cacheTickCounter[idx].ShowPercent == showPercent && cacheTickCounter[idx].EqualsInput(input))
                    {
                        return(cacheTickCounter[idx]);
                    }
                }
            }

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

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

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

                TickCounter[] tmp = new TickCounter[cacheTickCounter == null ? 1 : cacheTickCounter.Length + 1];
                if (cacheTickCounter != null)
                {
                    cacheTickCounter.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheTickCounter    = tmp;
                return(indicator);
            }
        }
Пример #2
0
        /// <summary>
        /// Displays the tick count of a bar.
        /// </summary>
        /// <returns></returns>
        public TickCounter TickCounter(Data.IDataSeries input, bool countDown, bool showPercent)
        {
            if (cacheTickCounter != null)
                for (int idx = 0; idx < cacheTickCounter.Length; idx++)
                    if (cacheTickCounter[idx].CountDown == countDown && cacheTickCounter[idx].ShowPercent == showPercent && cacheTickCounter[idx].EqualsInput(input))
                        return cacheTickCounter[idx];

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

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

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

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