Ejemplo n.º 1
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            if (CurrentBar < 5)
            {
                return;
            }


            if (MACD(12, 26, 9).Diff[0] >= MACD(12, 26, 9).Diff[1])
            {
                if ((MACD(12, 26, 9).Diff[1] < MACD(12, 26, 9).Diff[2]) & (MACD(12, 26, 9).Diff[2] < MACD(12, 26, 9).Diff[3]) & (MACD(12, 26, 9).Diff[3] < MACD(12, 26, 9).Diff[4]) & (MACD(12, 26, 9).Diff[4] < MACD(12, 26, 9).Diff[5]))
                {
                    Plot5.Set(MACD(12, 26, 9).Diff[0]);
                }

                else
                {
                    Plot5.Set(0);
                    Plot1.Set(MACD(12, 26, 9).Diff[0]);
                }
            }

            else
            {
                Plot1.Set(0);
            }

            if (MACD(12, 26, 9).Diff[0] < MACD(12, 26, 9).Diff[1])
            {
                if ((MACD(12, 26, 9).Diff[1] >= MACD(12, 26, 9).Diff[2]) & (MACD(12, 26, 9).Diff[2] >= MACD(12, 26, 9).Diff[3]) & (MACD(12, 26, 9).Diff[3] >= MACD(12, 26, 9).Diff[4]) & (MACD(12, 26, 9).Diff[4] >= MACD(12, 26, 9).Diff[5]))
                {
                    Plot4.Set(MACD(12, 26, 9).Diff[0]);
                }

                else
                {
                    Plot4.Set(0);
                    Plot0.Set(MACD(12, 26, 9).Diff[0]);
                }
            }

            else
            {
                Plot0.Set(0);
            }
        }
        protected override void CalcBar()
        {
            if (Bars.LastBarInSession)
            {
                m_upperband.Value = (Bars.Close[0] * (1 + (numdevs * volstddev[0] / Math.Sqrt(252))));
                m_lowerband.Value = (Bars.Close[0] * (1 - (numdevs * volstddev[0] / Math.Sqrt(252))));
            }
            else
            {
                m_upperband.Value = (Bars.Close[1] * (1 + (numdevs * volstddev[0] / Math.Sqrt(252))));
                m_lowerband.Value = (Bars.Close[1] * (1 - (numdevs * volstddev[0] / Math.Sqrt(252))));
            }

            Plot1.Set(0, m_upperband.Value);
            Plot2.Set(0, m_lowerband.Value);

            if (enable_depth)
            {
                Plot3.Set(0, (Bars.Close[0] - m_upperband.Value) / (m_upperband.Value - m_lowerband.Value));
                Plot4.Set(0, (m_lowerband.Value - Bars.Close[0]) / (m_upperband.Value - m_lowerband.Value));
            }
        }