コード例 #1
0
        /// <summary>
        /// The balance of power indicator measures the strength of the bulls vs. bears by assessing the ability of each to push price to an extreme level.
        /// </summary>
        /// <returns></returns>
        public BOP BOP(Data.IDataSeries input, int smooth)
        {
            if (cacheBOP != null)
            {
                for (int idx = 0; idx < cacheBOP.Length; idx++)
                {
                    if (cacheBOP[idx].Smooth == smooth && cacheBOP[idx].EqualsInput(input))
                    {
                        return(cacheBOP[idx]);
                    }
                }
            }

            lock (checkBOP)
            {
                checkBOP.Smooth = smooth;
                smooth          = checkBOP.Smooth;

                if (cacheBOP != null)
                {
                    for (int idx = 0; idx < cacheBOP.Length; idx++)
                    {
                        if (cacheBOP[idx].Smooth == smooth && cacheBOP[idx].EqualsInput(input))
                        {
                            return(cacheBOP[idx]);
                        }
                    }
                }

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

                BOP[] tmp = new BOP[cacheBOP == null ? 1 : cacheBOP.Length + 1];
                if (cacheBOP != null)
                {
                    cacheBOP.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheBOP            = tmp;
                return(indicator);
            }
        }
コード例 #2
0
ファイル: BOP.cs プロジェクト: redrhino/NinjaTrader.Base
        /// <summary>
        /// The balance of power indicator measures the strength of the bulls vs. bears by assessing the ability of each to push price to an extreme level.
        /// </summary>
        /// <returns></returns>
        public BOP BOP(Data.IDataSeries input, int smooth)
        {
            if (cacheBOP != null)
                for (int idx = 0; idx < cacheBOP.Length; idx++)
                    if (cacheBOP[idx].Smooth == smooth && cacheBOP[idx].EqualsInput(input))
                        return cacheBOP[idx];

            lock (checkBOP)
            {
                checkBOP.Smooth = smooth;
                smooth = checkBOP.Smooth;

                if (cacheBOP != null)
                    for (int idx = 0; idx < cacheBOP.Length; idx++)
                        if (cacheBOP[idx].Smooth == smooth && cacheBOP[idx].EqualsInput(input))
                            return cacheBOP[idx];

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

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