Exemplo n.º 1
0
        /// <summary>
        /// Colors the MACD plot when rising or falling
        /// </summary>
        /// <returns></returns>
        public MACDUpDown MACDUpDown(Data.IDataSeries input, int fast, int slow, int smooth)
        {
            if (cacheMACDUpDown != null)
            {
                for (int idx = 0; idx < cacheMACDUpDown.Length; idx++)
                {
                    if (cacheMACDUpDown[idx].Fast == fast && cacheMACDUpDown[idx].Slow == slow && cacheMACDUpDown[idx].Smooth == smooth && cacheMACDUpDown[idx].EqualsInput(input))
                    {
                        return(cacheMACDUpDown[idx]);
                    }
                }
            }

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

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

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

                MACDUpDown[] tmp = new MACDUpDown[cacheMACDUpDown == null ? 1 : cacheMACDUpDown.Length + 1];
                if (cacheMACDUpDown != null)
                {
                    cacheMACDUpDown.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheMACDUpDown     = tmp;
                return(indicator);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Colors the MACD plot when rising or falling
        /// </summary>
        /// <returns></returns>
        public MACDUpDown MACDUpDown(Data.IDataSeries input, int fast, int slow, int smooth)
        {
            if (cacheMACDUpDown != null)
                for (int idx = 0; idx < cacheMACDUpDown.Length; idx++)
                    if (cacheMACDUpDown[idx].Fast == fast && cacheMACDUpDown[idx].Slow == slow && cacheMACDUpDown[idx].Smooth == smooth && cacheMACDUpDown[idx].EqualsInput(input))
                        return cacheMACDUpDown[idx];

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

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

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

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