Exemplo n.º 1
0
        /// <summary>
        /// The PPO (Percentage Price Oscillator) is based on two moving averages expressed as a percentage. The PPO is found by subtracting the longer MA from the shorter MA and then dividing the difference by the longer MA.
        /// </summary>
        /// <returns></returns>
        public PPO PPO(Data.IDataSeries input, int fast, int slow, int smooth)
        {
            if (cachePPO != null)
            {
                for (int idx = 0; idx < cachePPO.Length; idx++)
                {
                    if (cachePPO[idx].Fast == fast && cachePPO[idx].Slow == slow && cachePPO[idx].Smooth == smooth && cachePPO[idx].EqualsInput(input))
                    {
                        return(cachePPO[idx]);
                    }
                }
            }

            lock (checkPPO)
            {
                checkPPO.Fast   = fast;
                fast            = checkPPO.Fast;
                checkPPO.Slow   = slow;
                slow            = checkPPO.Slow;
                checkPPO.Smooth = smooth;
                smooth          = checkPPO.Smooth;

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

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

                PPO[] tmp = new PPO[cachePPO == null ? 1 : cachePPO.Length + 1];
                if (cachePPO != null)
                {
                    cachePPO.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cachePPO            = tmp;
                return(indicator);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// The PPO (Percentage Price Oscillator) is based on two moving averages expressed as a percentage. The PPO is found by subtracting the longer MA from the shorter MA and then dividing the difference by the longer MA.
        /// </summary>
        /// <returns></returns>
        public PPO PPO(Data.IDataSeries input, int fast, int slow, int smooth)
        {
            if (cachePPO != null)
                for (int idx = 0; idx < cachePPO.Length; idx++)
                    if (cachePPO[idx].Fast == fast && cachePPO[idx].Slow == slow && cachePPO[idx].Smooth == smooth && cachePPO[idx].EqualsInput(input))
                        return cachePPO[idx];

            lock (checkPPO)
            {
                checkPPO.Fast = fast;
                fast = checkPPO.Fast;
                checkPPO.Slow = slow;
                slow = checkPPO.Slow;
                checkPPO.Smooth = smooth;
                smooth = checkPPO.Smooth;

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

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

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