Esempio n. 1
0
 public static DateTime GetEndTime(this ChartTrendLine line)
 {
     return(line.Time1 > line.Time2 ? line.Time1 : line.Time2);
 }
Esempio n. 2
0
        private void DrawOrUpdateAcLabel(ChartTriangle leftTriangle, ChartTriangle rightTriangle, ChartTrendLine line, long id, ChartText label = null)
        {
            var labelTime = line.GetLineCenterTime();

            var labelY = line.GetLineCenterY();

            var acLength = rightTriangle.Y2 - leftTriangle.Y2;

            var xaLength = leftTriangle.Y2 - leftTriangle.Y1;

            var ratio = Math.Round(1 + acLength / xaLength, 3);

            if (label == null)
            {
                DrawLabelText(ratio.ToString(), labelTime, labelY, id, objectNameKey: "AC");
            }
            else
            {
                label.Text = ratio.ToString();
                label.Time = labelTime;
                label.Y    = labelY;
            }
        }
Esempio n. 3
0
 private bool IsSignalLine(ChartTrendLine line)
 {
     return(SignalLineLabels.AllLables.Contains(line.Comment));
 }
        private bool _checkFeedback(ChartTrendLine myline, string[] directive)
        {
            // --> Mi aspetto 5 elementi altrimenti avanti un altro
            if (directive.Length != 5)
            {
                return(false);
            }

            // --> L'ultima ha la precedenza, ovvero l'apertura
            if (directive[2] == Flag.OpenBuyStop)
            {
                myline.ToBuy().Stop();
            }
            else if (directive[2] == Flag.OpenBuyStopBar)
            {
                myline.ToBuy().StopBar();
            }
            else if (directive[2] == Flag.OpenBuyLimit)
            {
                myline.ToBuy().Limit();
            }
            else if (directive[2] == Flag.OpenSellStop)
            {
                myline.ToSell().Stop();
            }
            else if (directive[2] == Flag.OpenSellStopBar)
            {
                myline.ToSell().StopBar();
            }
            else if (directive[2] == Flag.OpenSellLimit)
            {
                myline.ToSell().Limit();
            }
            // --> Le chiusure
            else if (directive[1] == Flag.Over || directive[1] == Flag.Under)
            {
                myline.ToClose();
            }
            else if (directive[1] == Flag.OverBar || directive[1] == Flag.UnderBar)
            {
                myline.ToCloseBar();
            }
            // --> Gli alerts
            else if (directive[0] == Flag.Over || directive[0] == Flag.Under)
            {
                myline.ToAlert();
            }
            else if (directive[0] == Flag.OverBar || directive[0] == Flag.UnderBar)
            {
                myline.ToAlertBar();
            }
            else if (directive[0] == Flag.DISABLED && directive[1] == Flag.DISABLED && directive[2] == Flag.DISABLED)
            {
                myline.ToAllDisabled();
            }
            else
            {
                return(false);
            }

            return(true);
        }
 public static void ToCloseBar(this ChartTrendLine MyTrendLine)
 {
     MyTrendLine.Color     = ColorClose;
     MyTrendLine.LineStyle = LineStyle.DotsVeryRare;
     MyTrendLine.Thickness = 2;
 }
 public static void ToAlertBar(this ChartTrendLine MyTrendLine)
 {
     MyTrendLine.Color     = ColorAlert;
     MyTrendLine.LineStyle = LineStyle.DotsVeryRare;
     MyTrendLine.Thickness = 1;
 }
 public static void Limit(this ChartTrendLine MyTrendLine)
 {
     MyTrendLine.LineStyle = LineStyle.Solid;
 }
Esempio n. 8
0
        private void DrawNonInteractiveObjects(ChartTrendLine firstLine, ChartTrendLine thirdLine, ChartTrendLine fifthLine, long id)
        {
            var firstLineName = GetObjectName("FirstConnectionLine", id);

            _firstConnectionLine = Chart.DrawTrendLine(firstLineName, firstLine.Time2, firstLine.Y2, thirdLine.Time2, thirdLine.Y2, Color, 1, LineStyle.Dots);

            _firstConnectionLine.IsInteractive = true;
            _firstConnectionLine.IsLocked      = true;

            var secondLineName = GetObjectName("SecondConnectionLine", id);

            _secondConnectionLine = Chart.DrawTrendLine(secondLineName, thirdLine.Time2, thirdLine.Y2, fifthLine.Time2, fifthLine.Y2, Color, 1, LineStyle.Dots);

            _secondConnectionLine.IsInteractive = true;
            _secondConnectionLine.IsLocked      = true;
        }
Esempio n. 9
0
 private void DrawLabels(ChartTrendLine firstLine, ChartTrendLine thirdLine, ChartTrendLine fifthLine, ChartTrendLine firstConnectionLine, ChartTrendLine secondConnectionLine, long id)
 {
     DrawOrUpdateFirstConnectionLineLabel(firstLine, thirdLine, firstConnectionLine, id);
     DrawOrUpdateSecondConnectionLineLabel(fifthLine, thirdLine, secondConnectionLine, id);
 }
Esempio n. 10
0
 public static TimeSpan GetTimeDelta(this ChartTrendLine line)
 {
     return(line.GetEndTime() - line.GetStartTime());
 }
Esempio n. 11
0
 public static DateTime GetLineCenterTime(this ChartTrendLine line)
 {
     return(line.Time1.AddMilliseconds((line.Time2 - line.Time1).TotalMilliseconds / 2));
 }
Esempio n. 12
0
 public static double GetBottomPrice(this ChartTrendLine line)
 {
     return(line.Y2 > line.Y1 ? line.Y1 : line.Y2);
 }
Esempio n. 13
0
 public static double GetTopPrice(this ChartTrendLine line)
 {
     return(line.Y2 > line.Y1 ? line.Y2 : line.Y1);
 }
Esempio n. 14
0
 public static double GetEndBarIndex(this ChartTrendLine line, Bars bars, Symbol symbol)
 {
     return(bars.GetBarIndex(line.GetEndTime(), symbol));
 }
Esempio n. 15
0
        protected override void OnDrawingStopped()
        {
            _mainFanLine = null;

            _sideFanLines.Clear();
        }
Esempio n. 16
0
        private void DrawOrUpdateSecondConnectionLineLabel(ChartTrendLine fifthLine, ChartTrendLine thirdLine, ChartTrendLine secondConnectionLine, long id, ChartText label = null)
        {
            var fifthLineLength = fifthLine.Y2 - fifthLine.Y1;

            var diffLength = thirdLine.Y2 - fifthLine.Y2;

            var ratio = Math.Round(diffLength / fifthLineLength, 3);

            var labelTime = secondConnectionLine.GetLineCenterTime();

            var labelY = secondConnectionLine.GetLineCenterY();

            if (label == null)
            {
                DrawLabelText(ratio.ToString(), labelTime, labelY, id, objectNameKey: "SecondConnection");
            }
            else
            {
                label.Text = ratio.ToString();
                label.Time = labelTime;
                label.Y    = labelY;
            }
        }
Esempio n. 17
0
        private void DrawLabels(ChartTrendLine firstLine, ChartTrendLine secondLine, ChartTrendLine thirdLine, ChartTrendLine fourthLine, ChartTrendLine fifthLine, long id)
        {
            switch (Degree)
            {
            case ElliottWaveDegree.SuperMellennium:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("((W))", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("((X))", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("((Y))", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("((X2))", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("((Z))", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.Mellennium:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("(W)", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("(X)", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("(Y)", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("(X2)", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("(Z)", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.SubMellennium:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("W", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("X", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("Y", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("X2", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("Z", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.GrandSuperCycle:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("((w))", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("((x))", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("((y))", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("((x2))", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("((z))", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.SuperCycle:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("(w)", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("(x)", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("(y)", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("(x2)", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("(z)", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.Cycle:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("w", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("x", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("y", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("x2", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("z", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.Primary:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("((W))", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("((X))", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("((Y))", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("((X2))", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("((Z))", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Intermediate:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("(W)", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("(X)", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("(Y)", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("(X2)", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("(Z)", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Minor:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("W", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("X", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("Y", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("X2", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("Z", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Minute:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("((w))", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("((x))", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("((y))", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("((x2))", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("((z))", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Minuette:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("(w)", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("(x)", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("(y)", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("(x2)", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("(z)", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.SubMinuette:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("w", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("x", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("y", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("x2", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("z", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Micro:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, fontSize: 7);
                DrawLabelText("((W))", secondLine.Time1, secondLine.Y1, id, fontSize: 7);
                DrawLabelText("((X))", thirdLine.Time1, thirdLine.Y1, id, fontSize: 7);
                DrawLabelText("((Y))", fourthLine.Time1, fourthLine.Y1, id, fontSize: 7);
                DrawLabelText("((X2))", fifthLine.Time1, fifthLine.Y1, id, fontSize: 7);
                DrawLabelText("((Z))", fifthLine.Time2, fifthLine.Y2, id, fontSize: 7);
                break;

            case ElliottWaveDegree.SubMicro:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, fontSize: 7);
                DrawLabelText("(W)", secondLine.Time1, secondLine.Y1, id, fontSize: 7);
                DrawLabelText("(X)", thirdLine.Time1, thirdLine.Y1, id, fontSize: 7);
                DrawLabelText("(Y)", fourthLine.Time1, fourthLine.Y1, id, fontSize: 7);
                DrawLabelText("(X2)", fifthLine.Time1, fifthLine.Y1, id, fontSize: 7);
                DrawLabelText("(Z)", fifthLine.Time2, fifthLine.Y2, id, fontSize: 7);
                break;

            case ElliottWaveDegree.Minuscule:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, fontSize: 7);
                DrawLabelText("W", secondLine.Time1, secondLine.Y1, id, fontSize: 7);
                DrawLabelText("X", thirdLine.Time1, thirdLine.Y1, id, fontSize: 7);
                DrawLabelText("Y", fourthLine.Time1, fourthLine.Y1, id, fontSize: 7);
                DrawLabelText("X2", fifthLine.Time1, fifthLine.Y1, id, fontSize: 7);
                DrawLabelText("Z", fifthLine.Time2, fifthLine.Y2, id, fontSize: 7);
                break;
            }
        }
        private void DrawLabels(ChartTrendLine firstLine, ChartTrendLine secondLine, ChartTrendLine thirdLine, ChartTrendLine fourthLine, ChartTrendLine fifthLine, long id)
        {
            switch (Degree)
            {
            case ElliottWaveDegree.SuperMellennium:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("((1))", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("((2))", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("((3))", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("((4))", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("((5))", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.Mellennium:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("(1)", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("(2)", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("(3)", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("(4)", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("(5)", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.SubMellennium:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("1", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("2", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("3", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("4", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("5", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.GrandSuperCycle:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("((I))", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("((II))", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("((III))", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("((IV))", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("((V))", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.SuperCycle:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("(I)", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("(II)", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("(III)", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("(IV)", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("(V)", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.Cycle:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("I", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("II", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("III", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("IV", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("V", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.Primary:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("((1))", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("((2))", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("((3))", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("((4))", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("((5))", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Intermediate:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("(1)", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("(2)", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("(3)", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("(4)", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("(5)", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Minor:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("1", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("2", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("3", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("4", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("5", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Minute:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("((i))", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("((ii))", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("((iii))", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("((iv))", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("((v))", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Minuette:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("(i)", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("(ii)", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("(iii)", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("(iv)", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("(v)", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.SubMinuette:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("i", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("ii", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("iii", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("iv", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("v", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Micro:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, fontSize: 7);
                DrawLabelText("((1))", secondLine.Time1, secondLine.Y1, id, fontSize: 7);
                DrawLabelText("((2))", thirdLine.Time1, thirdLine.Y1, id, fontSize: 7);
                DrawLabelText("((3))", fourthLine.Time1, fourthLine.Y1, id, fontSize: 7);
                DrawLabelText("((4))", fifthLine.Time1, fifthLine.Y1, id, fontSize: 7);
                DrawLabelText("((5))", fifthLine.Time2, fifthLine.Y2, id, fontSize: 7);
                break;

            case ElliottWaveDegree.SubMicro:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, fontSize: 7);
                DrawLabelText("(1)", secondLine.Time1, secondLine.Y1, id, fontSize: 7);
                DrawLabelText("(2)", thirdLine.Time1, thirdLine.Y1, id, fontSize: 7);
                DrawLabelText("(3)", fourthLine.Time1, fourthLine.Y1, id, fontSize: 7);
                DrawLabelText("(4)", fifthLine.Time1, fifthLine.Y1, id, fontSize: 7);
                DrawLabelText("(5)", fifthLine.Time2, fifthLine.Y2, id, fontSize: 7);
                break;

            case ElliottWaveDegree.Minuscule:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, fontSize: 7);
                DrawLabelText("1", secondLine.Time1, secondLine.Y1, id, fontSize: 7);
                DrawLabelText("2", thirdLine.Time1, thirdLine.Y1, id, fontSize: 7);
                DrawLabelText("3", fourthLine.Time1, fourthLine.Y1, id, fontSize: 7);
                DrawLabelText("4", fifthLine.Time1, fifthLine.Y1, id, fontSize: 7);
                DrawLabelText("5", fifthLine.Time2, fifthLine.Y2, id, fontSize: 7);
                break;
            }
        }
 public static void StopBar(this ChartTrendLine MyTrendLine)
 {
     MyTrendLine.LineStyle = LineStyle.DotsVeryRare;
 }
Esempio n. 20
0
        public FrmWrapper(ChartTrendLine trendline)
        {
            MyTrendLine = trendline;

            InitializeComponent();
        }
        private void _manageTrendLine(OnState mystate, ChartTrendLine myline)
        {
            // --> Se non è inizializzata non devo fare nulla
            if (myline.Comment == null)
            {
                return;
            }

            // --> Potrebbe essere in un protoccollo non in linea con le aspettative
            string[] directive = myline.Comment.Split(Flag.Separator);

            // --> Aggiorno il feedback visivo
            if (!_checkFeedback(myline, directive))
            {
                return;
            }

            // --> Se la trendline non è infinita allora devo controllare il tempo, inizio con le scadute
            if (!myline.ExtendToInfinity && myline.Time1 < Bars.LastBar.OpenTime && myline.Time2 < Bars.LastBar.OpenTime)
            {
                myline.ToDelivered();
                return;
            }
            else if (myline.Time1 > Bars.LastBar.OpenTime && myline.Time2 > Bars.LastBar.OpenTime)
            {
                // --> Sono nel futuro, non opero
                return;
            }

            // --> Prelevo il prezzo della trendline
            double lineprice = Math.Round(myline.CalculateY(Chart.BarsTotal - 1), Symbol.Digits);

            switch (mystate)
            {
            // --> Solo controlli per le bar,
            case OnState.Bar:

                // --> Prelevo lo stato attuale del prezzo
                CurrentStateLine myPricePosition = _checkCurrentState(lineprice);

                if (myPricePosition == CurrentStateLine.OverBar)
                {
                    if (directive[0] == Flag.OverBar)
                    {
                        _alert(myline, directive[4]);
                        directive[0] = Flag.DISABLED;
                    }

                    if (directive[1] == Flag.OverBar)
                    {
                        _close(myline);
                        directive[1] = Flag.DISABLED;
                    }

                    if (directive[2] == Flag.OpenBuyStopBar)
                    {
                        _open(myline, TradeType.Buy, directive[3]);
                        directive[2] = Flag.DISABLED;
                    }
                }
                else if (myPricePosition == CurrentStateLine.UnderBar)
                {
                    if (directive[0] == Flag.UnderBar)
                    {
                        _alert(myline, directive[4]);
                        directive[0] = Flag.DISABLED;
                    }

                    if (directive[1] == Flag.UnderBar)
                    {
                        _close(myline);
                        directive[1] = Flag.DISABLED;
                    }

                    if (directive[2] == Flag.OpenSellStopBar)
                    {
                        _open(myline, TradeType.Sell, directive[3]);
                        directive[2] = Flag.DISABLED;
                    }
                }
                else if (myPricePosition == CurrentStateLine.OnGAP)
                {
                    double gapBar = Math.Round(Math.Abs(Bars.ClosePrices.Last(1) - Bars.OpenPrices.Last(0)) / Symbol.PipSize, 2);

                    // --> Procedo se il GAP è nella norma
                    if (gapBar <= MaxGAPBar)
                    {
                        _alert(myline, directive[4]);
                        _close(myline);

                        switch (directive[2])
                        {
                        case Flag.OpenBuyStopBar:

                            _open(myline, TradeType.Buy, directive[3]);
                            break;

                        case Flag.OpenSellStopBar:

                            _open(myline, TradeType.Sell, directive[3]);
                            break;
                        }

                        _log("GAP (" + gapBar + ") then Triggered (check cBot setup)");
                    }
                    else
                    {
                        _log("GAP (" + gapBar + ") then Disabled (check cBot setup)");
                    }

                    // --> Disabilito a prescindere
                    directive[0] = Flag.DISABLED;
                    directive[1] = Flag.DISABLED;
                    directive[2] = Flag.DISABLED;
                }

                break;

            default:


                // --> Prelevo lo stato attuale del prezzo
                CurrentStateLine myPricePositionForAsk = _checkCurrentState(lineprice, Ask);
                CurrentStateLine myPricePositionForBid = _checkCurrentState(lineprice, Bid);

                if (myPricePositionForAsk == CurrentStateLine.Over)
                {
                    if (directive[0] == Flag.Over)
                    {
                        _alert(myline, directive[4]);
                        directive[0] = Flag.DISABLED;
                    }

                    /*
                     * if (directive[1] == Flag.Over)
                     * {
                     *
                     *  _close(myline);
                     *  directive[1] = Flag.DISABLED;
                     *
                     * }
                     */
                    if (directive[2] == Flag.OpenBuyStop)
                    {
                        _open(myline, TradeType.Buy, directive[3]);
                        directive[2] = Flag.DISABLED;
                    }
                }
                else if (myPricePositionForAsk == CurrentStateLine.Under)
                {
                    if (directive[0] == Flag.Under)
                    {
                        _alert(myline, directive[4]);
                        directive[0] = Flag.DISABLED;
                    }

                    if (directive[1] == Flag.Under)
                    {
                        _close(myline);
                        directive[1] = Flag.DISABLED;
                    }

                    if (directive[2] == Flag.OpenBuyLimit)
                    {
                        _open(myline, TradeType.Buy, directive[3]);
                        directive[2] = Flag.DISABLED;
                    }
                }

                if (myPricePositionForBid == CurrentStateLine.Over)
                {
                    if (directive[0] == Flag.Over)
                    {
                        _alert(myline, directive[4]);
                        directive[0] = Flag.DISABLED;
                    }

                    if (directive[1] == Flag.Over)
                    {
                        _close(myline);
                        directive[1] = Flag.DISABLED;
                    }

                    if (directive[2] == Flag.OpenSellLimit)
                    {
                        _open(myline, TradeType.Sell, directive[3]);
                        directive[2] = Flag.DISABLED;
                    }
                }
                else if (myPricePositionForBid == CurrentStateLine.Under)
                {
                    if (directive[0] == Flag.Under)
                    {
                        _alert(myline, directive[4]);
                        directive[0] = Flag.DISABLED;
                    }

                    /*
                     * if (directive[1] == Flag.Under)
                     * {
                     *
                     *  _close(myline);
                     *  directive[1] = Flag.DISABLED;
                     *
                     * }
                     */
                    if (directive[2] == Flag.OpenSellStop)
                    {
                        _open(myline, TradeType.Sell, directive[3]);
                        directive[2] = Flag.DISABLED;
                    }
                }

                break;
            }

            // --> Ricostruisco le direttive
            myline.Comment = string.Join("/", directive);
        }
        private void UpdateLines(ChartTrendLine zeroLine, ChartTrendLine onePercentLine, ChartTrendLine updatedLine, long id)
        {
            if (updatedLine == zeroLine)
            {
                zeroLine.RefelectOnOtherLine(onePercentLine, Chart.Bars, Chart.Symbol);
            }
            else
            {
                onePercentLine.RefelectOnOtherLine(zeroLine, Chart.Bars, Chart.Symbol);
            }

            DrawFibonacciLevels(zeroLine, onePercentLine, zeroLine.GetSlope(), id, updateMainLineStlyes: false);
        }
 public static void ToAllDisabled(this ChartTrendLine MyTrendLine)
 {
     MyTrendLine.Color     = ColorAllDisabled;
     MyTrendLine.LineStyle = LineStyle.DotsRare;
     MyTrendLine.Thickness = 1;
 }
        private Dictionary <double, ChartTrendLine> DrawFibonacciLevels(ChartTrendLine zeroLine, ChartTrendLine onePercentLine, double zeroLineSlope, long id, bool updateMainLineStlyes = true)
        {
            var zeroFirstBarIndex  = Chart.Bars.GetBarIndex(zeroLine.Time1, Chart.Symbol);
            var zeroSecondBarIndex = Chart.Bars.GetBarIndex(zeroLine.Time2, Chart.Symbol);

            var onePercentFirstBarIndex = Chart.Bars.GetBarIndex(onePercentLine.Time1, Chart.Symbol);

            var barsDelta  = Math.Abs(zeroFirstBarIndex - onePercentFirstBarIndex);
            var priceDelta = Math.Abs(zeroLine.Y1 - onePercentLine.Y1);

            var zeroLineBarsDelta  = zeroLine.GetBarsNumber(Chart.Bars, Chart.Symbol);
            var zeroLinePriceDelta = zeroLine.GetPriceDelta();

            var result = new Dictionary <double, ChartTrendLine>();

            foreach (var level in _fibonacciLevels)
            {
                if (level.Percent == 0 && updateMainLineStlyes)
                {
                    zeroLine.Color     = level.LineColor;
                    zeroLine.Thickness = level.Thickness;
                    zeroLine.LineStyle = level.Style;
                }
                else if (level.Percent == 1 && updateMainLineStlyes)
                {
                    onePercentLine.Color     = level.LineColor;
                    onePercentLine.Thickness = level.Thickness;
                    onePercentLine.LineStyle = level.Style;
                }
                else
                {
                    var levelName = GetObjectName(string.Format("Level_{0}", level.Percent.ToString(CultureInfo.InvariantCulture)), id);

                    var barsAmount  = barsDelta * level.Percent;
                    var priceAmount = priceDelta * level.Percent;

                    double firstBarIndex, secondBarIndex, firstPrice, secondPrice;

                    if (onePercentLine.Time1 < zeroLine.Time1)
                    {
                        firstPrice = onePercentLine.Y1 > zeroLine.Y1 ? zeroLine.Y1 + priceAmount : zeroLine.Y1 - priceAmount;

                        if (zeroLine.Time1 < zeroLine.Time2)
                        {
                            firstBarIndex  = zeroFirstBarIndex - barsAmount;
                            secondBarIndex = firstBarIndex + zeroLineBarsDelta;

                            secondPrice = zeroLineSlope > 0 ? firstPrice + zeroLinePriceDelta : firstPrice - zeroLinePriceDelta;
                        }
                        else
                        {
                            firstBarIndex  = zeroFirstBarIndex - barsAmount;
                            secondBarIndex = firstBarIndex - zeroLineBarsDelta;

                            secondPrice = zeroLineSlope > 0 ? firstPrice - zeroLinePriceDelta : firstPrice + zeroLinePriceDelta;
                        }
                    }
                    else
                    {
                        firstPrice = onePercentLine.Y1 > zeroLine.Y1 ? zeroLine.Y1 + priceAmount : zeroLine.Y1 - priceAmount;

                        if (zeroLine.Time1 < zeroLine.Time2)
                        {
                            firstBarIndex  = zeroFirstBarIndex + barsAmount;
                            secondBarIndex = firstBarIndex + zeroLineBarsDelta;

                            secondPrice = zeroLineSlope > 0 ? firstPrice + zeroLinePriceDelta : firstPrice - zeroLinePriceDelta;
                        }
                        else
                        {
                            firstBarIndex  = zeroFirstBarIndex + barsAmount;
                            secondBarIndex = firstBarIndex - zeroLineBarsDelta;

                            secondPrice = zeroLineSlope > 0 ? firstPrice - zeroLinePriceDelta : firstPrice + zeroLinePriceDelta;
                        }
                    }

                    var firstTime  = Chart.Bars.GetOpenTime(firstBarIndex, Chart.Symbol);
                    var secondTime = Chart.Bars.GetOpenTime(secondBarIndex, Chart.Symbol);

                    var levelLine = Chart.Objects.FirstOrDefault(iObject => iObject.Name.Equals(levelName, StringComparison.OrdinalIgnoreCase)) as ChartTrendLine;

                    if (levelLine != null)
                    {
                        levelLine.Time1 = firstTime;
                        levelLine.Time2 = secondTime;

                        levelLine.Y1 = firstPrice;
                        levelLine.Y2 = secondPrice;
                    }
                    else
                    {
                        levelLine = Chart.DrawTrendLine(levelName, firstTime, firstPrice, secondTime, secondPrice, level.LineColor, level.Thickness, level.Style);
                    }

                    levelLine.IsInteractive = true;
                    levelLine.IsLocked      = true;

                    result.Add(level.Percent, levelLine);
                }
            }

            return(result);
        }
Esempio n. 25
0
        private void DrawLabels(ChartTriangle leftTriangle, ChartTriangle rightTriangle, ChartTrendLine acLine, ChartTrendLine xdLine, long id)
        {
            DrawLabelText("X", leftTriangle.Time1, leftTriangle.Y1, id);

            DrawLabelText("A", leftTriangle.Time2, leftTriangle.Y2, id);

            DrawLabelText("B", leftTriangle.Time3, leftTriangle.Y3, id);

            DrawLabelText("C", rightTriangle.Time2, rightTriangle.Y2, id);

            DrawLabelText("D", rightTriangle.Time3, rightTriangle.Y3, id);

            DrawOrUpdateAcLabel(leftTriangle, rightTriangle, acLine, id);

            DrawOrUpdateXdLabel(leftTriangle, rightTriangle, xdLine, id);

            DrawOrUpdateBdLabel(rightTriangle, id);
        }
        protected override void OnDrawingStopped()
        {
            _mainLine = null;

            _levelLines.Clear();
        }
Esempio n. 27
0
        private void DrawLabels(ChartTrendLine firstLine, ChartTrendLine secondLine, ChartTrendLine thirdLine, ChartTrendLine fourthLine, ChartTrendLine fifthLine, long id)
        {
            switch (Degree)
            {
            case ElliottWaveDegree.SuperMellennium:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("((A))", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("((B))", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("((C))", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("((D))", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("((E))", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.Mellennium:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("(A)", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("(B)", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("(C)", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("(D)", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("(E)", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.SubMellennium:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("A", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("B", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("C", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("D", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("E", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.GrandSuperCycle:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("((a))", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("((b))", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("((c))", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("((d))", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("((e))", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.SuperCycle:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("(a)", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("(b)", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("(c)", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("(d)", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("(e)", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.Cycle:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, isBold: true);
                DrawLabelText("a", secondLine.Time1, secondLine.Y1, id, isBold: true);
                DrawLabelText("b", thirdLine.Time1, thirdLine.Y1, id, isBold: true);
                DrawLabelText("c", fourthLine.Time1, fourthLine.Y1, id, isBold: true);
                DrawLabelText("d", fifthLine.Time1, fifthLine.Y1, id, isBold: true);
                DrawLabelText("e", fifthLine.Time2, fifthLine.Y2, id, isBold: true);
                break;

            case ElliottWaveDegree.Primary:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("((A))", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("((B))", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("((C))", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("((D))", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("((E))", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Intermediate:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("(A)", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("(B)", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("(C)", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("(D)", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("(E)", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Minor:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("A", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("B", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("C", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("D", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("E", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Minute:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("((a))", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("((b))", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("((c))", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("((d))", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("((e))", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Minuette:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("(a)", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("(b)", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("(c)", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("(d)", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("(e)", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.SubMinuette:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, fontSize: 10);
                DrawLabelText("a", secondLine.Time1, secondLine.Y1, id, fontSize: 10);
                DrawLabelText("b", thirdLine.Time1, thirdLine.Y1, id, fontSize: 10);
                DrawLabelText("c", fourthLine.Time1, fourthLine.Y1, id, fontSize: 10);
                DrawLabelText("d", fifthLine.Time1, fifthLine.Y1, id, fontSize: 10);
                DrawLabelText("e", fifthLine.Time2, fifthLine.Y2, id, fontSize: 10);
                break;

            case ElliottWaveDegree.Micro:
                DrawLabelText("((0))", firstLine.Time1, firstLine.Y1, id, fontSize: 7);
                DrawLabelText("((A))", secondLine.Time1, secondLine.Y1, id, fontSize: 7);
                DrawLabelText("((B))", thirdLine.Time1, thirdLine.Y1, id, fontSize: 7);
                DrawLabelText("((C))", fourthLine.Time1, fourthLine.Y1, id, fontSize: 7);
                DrawLabelText("((D))", fifthLine.Time1, fifthLine.Y1, id, fontSize: 7);
                DrawLabelText("((E))", fifthLine.Time2, fifthLine.Y2, id, fontSize: 7);
                break;

            case ElliottWaveDegree.SubMicro:
                DrawLabelText("(0)", firstLine.Time1, firstLine.Y1, id, fontSize: 7);
                DrawLabelText("(A)", secondLine.Time1, secondLine.Y1, id, fontSize: 7);
                DrawLabelText("(B)", thirdLine.Time1, thirdLine.Y1, id, fontSize: 7);
                DrawLabelText("(C)", fourthLine.Time1, fourthLine.Y1, id, fontSize: 7);
                DrawLabelText("(D)", fifthLine.Time1, fifthLine.Y1, id, fontSize: 7);
                DrawLabelText("(E)", fifthLine.Time2, fifthLine.Y2, id, fontSize: 7);
                break;

            case ElliottWaveDegree.Minuscule:
                DrawLabelText("0", firstLine.Time1, firstLine.Y1, id, fontSize: 7);
                DrawLabelText("A", secondLine.Time1, secondLine.Y1, id, fontSize: 7);
                DrawLabelText("B", thirdLine.Time1, thirdLine.Y1, id, fontSize: 7);
                DrawLabelText("C", fourthLine.Time1, fourthLine.Y1, id, fontSize: 7);
                DrawLabelText("D", fifthLine.Time1, fifthLine.Y1, id, fontSize: 7);
                DrawLabelText("E", fifthLine.Time2, fifthLine.Y2, id, fontSize: 7);
                break;
            }
        }
        private void UpdatePattern(ChartTrendLine mainLine, IOrderedEnumerable <KeyValuePair <double, ChartTrendLine> > levelLines, Dictionary <double, ChartRectangle> levelRectangles, ChartObject updatedChartObject)
        {
            var verticalDelta = mainLine.GetPriceDelta();

            var previousLevelPrice = double.NaN;

            FibonacciLevel previousLevel = null;

            var startTime = mainLine.GetStartTime();
            var endTime   = mainLine.GetEndTime();

            foreach (var levelLine in levelLines)
            {
                var percent = levelLine.Key;

                var level = _levels.FirstOrDefault(iLevel => iLevel.Percent == percent);

                if (level == null)
                {
                    continue;
                }

                var levelAmount = percent == 0 ? 0 : verticalDelta * percent;

                var price = mainLine.Y2 > mainLine.Y1 ? mainLine.Y2 - levelAmount : mainLine.Y2 + levelAmount;

                levelLine.Value.Time1 = startTime;
                levelLine.Value.Time2 = endTime;

                levelLine.Value.Y1 = price;
                levelLine.Value.Y2 = price;

                if (previousLevel == null)
                {
                    previousLevelPrice = price;

                    previousLevel = level;

                    continue;
                }

                ChartRectangle levelRectangle;

                if (levelRectangles.TryGetValue(level.Percent, out levelRectangle))
                {
                    if (levelLine.Value == updatedChartObject)
                    {
                        levelRectangle.Color = Color.FromArgb(level.FillColor.A, levelLine.Value.Color);
                    }
                    else if (levelRectangle == updatedChartObject)
                    {
                        levelLine.Value.Color = Color.FromArgb(level.LineColor.A, levelRectangle.Color);
                    }
                }

                ChartRectangle previousLevelRectangle;

                if (!levelRectangles.TryGetValue(previousLevel.Percent, out previousLevelRectangle))
                {
                    continue;
                }

                previousLevelRectangle.Time1 = startTime;

                previousLevelRectangle.Time2 = previousLevel.ExtendToInfinity ? endTime.AddMonths(100) : endTime;

                previousLevelRectangle.Y1 = previousLevelPrice;
                previousLevelRectangle.Y2 = price;

                previousLevelPrice = price;
                previousLevel      = level;
            }
        }
Esempio n. 29
0
 public SignalLine(ChartTrendLine chartTrendLine, SignalType signalType, TradeType tradeType)
 {
     _chartTrendLine = chartTrendLine;
     SignalType      = signalType;
     TradeType       = tradeType;
 }
Esempio n. 30
0
 public static DateTime GetStartTime(this ChartTrendLine line)
 {
     return(line.Time1 > line.Time2 ? line.Time2 : line.Time1);
 }