Exemple #1
0
        /// <summary>
        /// Indicates the current buying or selling pressure as a perecentage. This is a tick by tick indicator. If 'Calculate on bar close' is true, the indicator values will always be 100.
        /// </summary>
        /// <returns></returns>
        public BuySellPressure BuySellPressure(Data.IDataSeries input)
        {
            if (cacheBuySellPressure != null)
            {
                for (int idx = 0; idx < cacheBuySellPressure.Length; idx++)
                {
                    if (cacheBuySellPressure[idx].EqualsInput(input))
                    {
                        return(cacheBuySellPressure[idx]);
                    }
                }
            }

            lock (checkBuySellPressure)
            {
                if (cacheBuySellPressure != null)
                {
                    for (int idx = 0; idx < cacheBuySellPressure.Length; idx++)
                    {
                        if (cacheBuySellPressure[idx].EqualsInput(input))
                        {
                            return(cacheBuySellPressure[idx]);
                        }
                    }
                }

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

                BuySellPressure[] tmp = new BuySellPressure[cacheBuySellPressure == null ? 1 : cacheBuySellPressure.Length + 1];
                if (cacheBuySellPressure != null)
                {
                    cacheBuySellPressure.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]  = indicator;
                cacheBuySellPressure = tmp;
                return(indicator);
            }
        }
        /// <summary>
        /// Indicates the current buying or selling pressure as a perecentage. This is a tick by tick indicator. If 'Calculate on bar close' is true, the indicator values will always be 100.
        /// </summary>
        /// <returns></returns>
        public BuySellPressure BuySellPressure(Data.IDataSeries input)
        {
            if (cacheBuySellPressure != null)
                for (int idx = 0; idx < cacheBuySellPressure.Length; idx++)
                    if (cacheBuySellPressure[idx].EqualsInput(input))
                        return cacheBuySellPressure[idx];

            lock (checkBuySellPressure)
            {
                if (cacheBuySellPressure != null)
                    for (int idx = 0; idx < cacheBuySellPressure.Length; idx++)
                        if (cacheBuySellPressure[idx].EqualsInput(input))
                            return cacheBuySellPressure[idx];

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

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