Esempio n. 1
0
        protected override void CalcBar()
        {
            m_mom.Value = Price.Momentum(Length);
            double m_accel = m_mom.Momentum(1);

            if (PublicFunctions.DoubleGreater(m_mom.Value, 0) &&
                PublicFunctions.DoubleGreater(m_accel, 0))
            {
                m_MomLE.Send(Bars.High[0] + Bars.Point);
            }
        }
        protected override void CalcBar()
        {
            m_mom.Value = Price.Momentum(Length);
            double m_accel = m_mom.Momentum(1);

            if (PublicFunctions.DoubleLess(m_mom.Value, 0) &&
                PublicFunctions.DoubleLess(m_accel, 0))
            {
                m_MomSE.Send(Bars.Low[0] - Bars.Point);
            }
        }
        protected override void CalcBar()
        {
            momentum_fast.Value = Price.Momentum(momentum_fast_length);
            momentum_slow.Value = Price.Momentum(momentum_slow_length);

            double momentum_fast_acceleration = momentum_fast.Momentum(1);
            double momentum_slow_acceleration = momentum_slow.Momentum(1);

            bool close_long, close_short, open_long, open_short;

            close_long  = (momentum_fast.Value < 0 - momentum_fast_offset) && (momentum_fast_acceleration < 0);
            close_short = (momentum_fast.Value > 0 + momentum_fast_offset) && (momentum_fast_acceleration > 0);
            open_long   = enable_long && (momentum_slow.Value > 0 + momentum_slow_offset) && (momentum_slow_acceleration > 0);
            open_short  = enable_short && (momentum_slow.Value < 0 - momentum_slow_offset) && (momentum_slow_acceleration < 0);

            if (StrategyInfo.MarketPosition == 0)
            {
                if (open_long)
                {
                    long_order.Send();
                }
                if (open_short)
                {
                    short_order.Send();
                }
            }
            else if (StrategyInfo.MarketPosition < 0)
            {
                if (close_short)
                {
                    close_short_order.Send();
                }
            }
            else if (StrategyInfo.MarketPosition > 0)
            {
                if (close_long)
                {
                    close_long_order.Send();
                }
            }
        }
Esempio n. 4
0
        protected override void CalcBar()
        {
            m_mom.Value = m_price.Momentum(length);
            var m_accel = m_mom.Momentum(1);

            Plot1.Set(0, m_mom.Value);
            Plot2.Set(0, 0);
            if (!upcolor.IsEmpty && !dncolor.IsEmpty)
            {
                var m_colorlevel = m_normgradientcolor1[0];
                if (m_applicationtype == 1)
                {
                    Plot1.Colors[0] = m_colorlevel;
                }
                else
                {
                    if (m_applicationtype > 1)
                    {
                        Plot1.Colors[0] = gridforegroundcolor;
                        Plot1.BGColor   = m_colorlevel;
                    }
                }
            }
            if (PublicFunctions.DoubleGreater(m_mom.Value, 0) &&
                PublicFunctions.DoubleGreater(m_accel, 0))
            {
                Alerts.Alert("Indicator positive and increasing");
            }
            else
            {
                if (PublicFunctions.DoubleLess(m_mom.Value, 0) &&
                    PublicFunctions.DoubleLess(m_accel, 0))
                {
                    Alerts.Alert("Indicator negative and decreasing");
                }
            }
        }