Ejemplo n.º 1
0
        protected override void OnBarUpdate()
        {
            if (CurrentBar < 3)
            {
                return;
            }
            bool condition1 = (ZLEMA(7)[0] < HeikenAshi().HAOpen[0] || ZLEMA(7)[0] < Median[0]) &&
                              ZLEMA(7)[0] < ZLEMA(21)[1] && HeikenAshi().HAClose[0] < ZLEMA(21)[2] &&
                              (MACD(12, 26, 9).Diff[0] < 0 || (HeikenAshi().HAClose[0] < ZLEMA(21)[2] && HeikenAshi().HAOpen[0] < ZLEMA(21)[2]) || Close[0] < SMA(21)[0] || ZLEMA(7)[0] < ZLEMA(21)[2]);

            bool condition2 = (ZLEMA(7)[0] > HeikenAshi().HAOpen[0] || ZLEMA(7)[0] > Median[0]) &&
                              ZLEMA(7)[0] > ZLEMA(21)[1] && HeikenAshi().HAClose[0] > ZLEMA(21)[2] &&
                              (MACD(12, 26, 9).Diff[0] > 0 || (HeikenAshi().HAClose[0] > ZLEMA(21)[2] && HeikenAshi().HAOpen[0] > ZLEMA(21)[2]) || Close[0] > SMA(21)[0] || ZLEMA(7)[0] > ZLEMA(21)[2]);

            bool condition3 = (Low[0] + ((High[0] - Low[0]) * 0.1)) < SMA(21)[0] &&
                              (High[0] - ((High[0] - Low[0]) * 0.1)) < SMA(21)[0] &&
                              ZLEMA(7)[0] < ZLEMA(7)[1] &&
                              ZLEMA(11)[0] < HeikenAshi().HAOpen[0];

            bool condition4 = condition1 && condition3;

            bool condition5 = condition1 || condition3;

            bool condition6 = ZLEMA(7)[0] < ZLEMA(7)[1] && ZLEMA(11)[0] < ZLEMA(11)[1] && ZLEMA(11)[0] < SMA(21)[0] && HeikenAshi().HAClose[0] < HeikenAshi().HAOpen[0] && Close[0] < Median[0];

            bool condition7 = HeikenAshi().HAClose[0] < SMA(21)[0] && ZLEMA(7)[0] < ZLEMA(7)[1] && High[0] < SMA(78)[0] && SMA(21)[0] < SMA(78)[0] && SMA(78)[0] < SMA(78)[3];

            if (condition4)
            {
                Condition4.Set(High[0] + TickSize);
            }
            if (condition5)
            {
                Condition5.Set(High[0] + 2 * TickSize);
            }
            if (condition2)
            {
                Condition2.Set(Low[0] - 3 * TickSize);
            }
            if (condition6 || condition7)
            {
                Condition67.Set(High[0] + 3 * TickSize);
            }
        }
Ejemplo n.º 2
0
        protected override void OnBarUpdate()
        {
            if (ChartControl == null || Bars == null)
            {
                return;
            }

            if (Displacement + (CalculateOnBarClose ? 1 : 0) > 0 && CurrentBar > 0 && BarColorSeries[1] != Color.Transparent)
            {
                InitColorSeries();
            }

            BarColorSeries.Set(Math.Max(0, CurrentBar + Math.Max(0, Displacement) + (CalculateOnBarClose ? 1 : 0)), Color.Transparent);
            CandleOutlineColorSeries.Set(Math.Max(0, CurrentBar + Math.Max(0, Displacement) + (CalculateOnBarClose ? 1 : 0)), Color.Transparent);
            Condition4.Reset();
            Condition5.Reset();
            Condition2.Reset();
            Condition67.Reset();
            if (CurrentBar == 0)
            {
                hao.Set(Open[0]);
                hah.Set(High[0]);
                hal.Set(Low[0]);
                hac.Set(Close[0]);
                return;
            }

            hac.Set((Open[0] + High[0] + Low[0] + Close[0]) * 0.25); // Calculate the close
            hao.Set((hao[1] + hac[1]) * 0.5);                        // Calculate the open
            hah.Set(Math.Max(High[0], hao[0]));                      // Calculate the high
            hal.Set(Math.Min(Low[0], hao[0]));                       // Calculate the low
            if (CurrentBar < 3)
            {
                return;
            }
            bool condition1 = (ZLEMA(7)[0] < hao[0] || ZLEMA(7)[0] < Median[0]) && ZLEMA(7)[0] < ZLEMA(21)[1] && hac[0] < ZLEMA(21)[2] &&
                              (MACD(12, 26, 9).Diff[0] < 0 || (hac[0] < ZLEMA(21)[2] && hao[0] < ZLEMA(21)[2]) || Close[0] < SMA(21)[0] || ZLEMA(7)[0] < ZLEMA(21)[2]);

            bool condition2 = (ZLEMA(7)[0] > hao[0] || ZLEMA(7)[0] > Median[0]) && ZLEMA(7)[0] > ZLEMA(21)[1] && hac[0] > ZLEMA(21)[2] &&
                              (MACD(12, 26, 9).Diff[0] > 0 || (hac[0] > ZLEMA(21)[2] && hao[0] > ZLEMA(21)[2]) || Close[0] > SMA(21)[0] || ZLEMA(7)[0] > ZLEMA(21)[2]);

            bool condition3 = (Low[0] + ((High[0] - Low[0]) * 0.1)) < SMA(21)[0] && (High[0] - ((High[0] - Low[0]) * 0.1)) < SMA(21)[0] && ZLEMA(7)[0] < ZLEMA(7)[1] && ZLEMA(11)[0] < hao[0];

            bool condition4 = condition1 && condition3;

            bool condition5 = condition1 || condition3;

            bool condition6 = ZLEMA(7)[0] < ZLEMA(7)[1] && ZLEMA(11)[0] < ZLEMA(11)[1] && ZLEMA(11)[0] < SMA(21)[0] && hac[0] < hao[0] && Close[0] < Median[0];

            bool condition7 = hac[0] < SMA(21)[0] && ZLEMA(7)[0] < ZLEMA(7)[1] && High[0] < SMA(78)[0] && SMA(21)[0] < SMA(78)[0] && SMA(78)[0] < SMA(78)[3];

            c4.Set(condition4);
            c5.Set(condition5);
            c2.Set(condition2);
            c67.Set(condition6 || condition7);

            if (condition6 || condition7)
            {
                if (st67 == SignalType.PLOT)
                {
                    Condition67.Set(hah[0] + 3 * TickSize);
                }
                else if (st67 == SignalType.BACKGROUNDCOLOR)
                {
                    BackColor = Plots[3].Pen.Color;
                }
            }
            if (condition2)
            {
                if (st2 == SignalType.PLOT)
                {
                    Condition2.Set(hal[0] - TickSize);
                }
                else if (st2 == SignalType.BACKGROUNDCOLOR)
                {
                    BackColor = Plots[2].Pen.Color;
                }
            }
            if (condition5)
            {
                if (st5 == SignalType.PLOT)
                {
                    Condition5.Set(hah[0] + 2 * TickSize);
                }
                else if (st5 == SignalType.BACKGROUNDCOLOR)
                {
                    BackColor = Plots[1].Pen.Color;
                }
            }
            if (condition4)
            {
                if (st4 == SignalType.PLOT)
                {
                    Condition4.Set(hah[0] + TickSize);
                }
                else if (st4 == SignalType.BACKGROUNDCOLOR)
                {
                    BackColor = Plots[0].Pen.Color;
                }
            }

            if (FirstTickOfBar && c4[1] && !c4[2] && playAlert)
            {
                PlaySound("Aler4.wav");
            }
        }