コード例 #1
0
        private void pgrdStudy_PropertyValueChanged(object sender, PropertyGridItemValueChangedEventArgs e)
        {
            Color StudyColor = (Color)pgrdStudy.Items[0].Value;

            Enums.LineStyle StudyLineStyle      = (Enums.LineStyle)pgrdStudy.Items[1].Value;
            int             StudyLineThickness  = (int)pgrdStudy.Items[2].Value;
            bool            StudyRightExtension = (bool)pgrdStudy.Items[3].Value;
            bool            StudyLeftExtension  = (bool)pgrdStudy.Items[4].Value;
            bool            StudyExtension      = (bool)pgrdStudy.Items[5].Value;
            double          StudyParam00        = (bool)pgrdStudy.Items[10].Value ? 0.0 : NULL_VALUE;
            double          StudyParam38        = (bool)pgrdStudy.Items[9].Value ? 0.382 : NULL_VALUE;
            double          StudyParam50        = (bool)pgrdStudy.Items[8].Value ? 0.5 : NULL_VALUE;
            double          StudyParam61        = (bool)pgrdStudy.Items[7].Value ? 0.618 : NULL_VALUE;
            double          StudyParam100       = (bool)pgrdStudy.Items[6].Value ? 1.0 : NULL_VALUE;
            double          StudyParam161       = (bool)pgrdStudy.Items[11].Value ? 1.618 : NULL_VALUE;
            double          StudyParam261       = (bool)pgrdStudy.Items[12].Value ? 2.618 : NULL_VALUE;
            double          StudyValue          = (double)pgrdStudy.Items[13].Value;

            infoGrid = new StudyInfo
            {
                ColorParameters          = StudyColor,
                LineStyleParameters      = StudyLineStyle,
                LineThicknessParameters  = StudyLineThickness,
                RightExtensionParameters = StudyRightExtension,
                LeftExtensionParameters  = StudyLeftExtension,
                ExtensionParameters      = StudyExtension
            };
            if (LineStudyType == "TrendLine")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, StudyRightExtension, StudyLeftExtension, 0);
            }
            else if (LineStudyType == "RayLine")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, true, StudyExtension, StudyExtension, 0);
            }
            else if (LineStudyType == "VerticalLine")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, false, false, 0);
            }
            else if (LineStudyType == "HorizontalLine")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, false, StudyExtension, StudyValue);
            }
            else if (LineStudyType == "Rectangle")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, false, false, 0);
            }
            else if (LineStudyType == "Ellipse")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, false, false, 0);
            }
            else if (LineStudyType == "Arrow")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, false, false, 0);
            }
            else if (LineStudyType == "FreeHand")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, false, false, 0);
            }
            else if (LineStudyType == "Polyline")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, false, false, 0);
            }
            else if (LineStudyType == "Channel")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, true, StudyExtension, 0);
            }
            else if (LineStudyType == "Fibonacci Arcs")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, true, false, 0);
            }
            else if (LineStudyType == "Fibonacci Fan")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, true, false, 0);
            }
            else if (LineStudyType == "Fibonacci Projections")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, true, false, 0);
                StockChartX1.UpdateFibonacciParams(LineStudyKey, StudyParam100, StudyParam61, StudyParam50, StudyParam38, StudyParam00, StudyParam161, StudyParam261, NULL_VALUE, NULL_VALUE, NULL_VALUE);
            }
            else if (LineStudyType == "Fibonacci Retracements")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, true, false, 0);
                StockChartX1.UpdateFibonacciParams(LineStudyKey, StudyParam100, StudyParam61, StudyParam50, StudyParam38, StudyParam00, StudyParam161, StudyParam261, NULL_VALUE, NULL_VALUE, NULL_VALUE);
            }
            else if (LineStudyType == "Fibonacci Timezones")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, true, false, 0);
            }
            else if (LineStudyType == "Speed Line")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, true, false, 0);
            }
            else if (LineStudyType == "Gann Fan")
            {
                StockChartX1.UpdateTrendLine(LineStudyKey, StudyLineStyle.GetHashCode(), StudyLineThickness,
                                             StudyColor.R, StudyColor.G,
                                             StudyColor.B, false, true, false, 0);
            }
        }
コード例 #2
0
 private void InitializeStudy()
 {
     if (LineStudyType == "TrendLine")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters      = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters  = StockChartX1.GetTrendLineThickness(LineStudyKey),
             RightExtensionParameters = StockChartX1.GetTrendLineRightExtension(LineStudyKey),
             LeftExtensionParameters  = StockChartX1.GetTrendLineLeftExtension(LineStudyKey)
         };
     }
     else if (LineStudyType == "RayLine") //Ray only have one Radius Extension or both Left\Right Extension
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey),
             ExtensionParameters     = StockChartX1.GetTrendLineRightExtension(LineStudyKey)
         };
     }
     else if (LineStudyType == "VerticalLine")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey)
         };
     }
     else if (LineStudyType == "HorizontalLine")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey),
             ExtensionParameters     = StockChartX1.GetTrendLineLeftExtension(LineStudyKey),
             ValuePosition           = Math.Round(StockChartX1.GetTrendLineValue(LineStudyKey), 3)
         };
     }
     else if (LineStudyType == "Rectangle")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey)
         };
     }
     else if (LineStudyType == "Ellipse")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey)
         };
     }
     else if (LineStudyType == "Arrow")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey)
         };
     }
     else if (LineStudyType == "FreeHand")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey)
         };
     }
     else if (LineStudyType == "Polyline")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey)
         };
     }
     else if (LineStudyType == "Channel")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey)
         };
     }
     else if (LineStudyType == "Fibonacci Arcs")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey)
         };
     }
     else if (LineStudyType == "Fibonacci Fan")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey)
         };
     }
     else if (LineStudyType == "Fibonacci Projections")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey),
             Percent1Parameters      = StockChartX1.GetFibonacciParameter(LineStudyKey, 0) != NULL_VALUE,
             Percent2Parameters      = StockChartX1.GetFibonacciParameter(LineStudyKey, 1) != NULL_VALUE,
             Percent3Parameters      = StockChartX1.GetFibonacciParameter(LineStudyKey, 2) != NULL_VALUE,
             Percent4Parameters      = StockChartX1.GetFibonacciParameter(LineStudyKey, 3) != NULL_VALUE,
             Percent5Parameters      = StockChartX1.GetFibonacciParameter(LineStudyKey, 4) != NULL_VALUE,
             Percent6Parameters      = StockChartX1.GetFibonacciParameter(LineStudyKey, 5) != NULL_VALUE,
             Percent7Parameters      = StockChartX1.GetFibonacciParameter(LineStudyKey, 6) != NULL_VALUE
         };
     }
     else if (LineStudyType == "Fibonacci Retracements")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey),
             Percent1Parameters      = StockChartX1.GetFibonacciParameter(LineStudyKey, 0) != NULL_VALUE,
             Percent2Parameters      = StockChartX1.GetFibonacciParameter(LineStudyKey, 1) != NULL_VALUE,
             Percent3Parameters      = StockChartX1.GetFibonacciParameter(LineStudyKey, 2) != NULL_VALUE,
             Percent4Parameters      = StockChartX1.GetFibonacciParameter(LineStudyKey, 3) != NULL_VALUE,
             Percent5Parameters      = StockChartX1.GetFibonacciParameter(LineStudyKey, 4) != NULL_VALUE,
             Percent6Parameters      = StockChartX1.GetFibonacciParameter(LineStudyKey, 5) != NULL_VALUE,
             Percent7Parameters      = StockChartX1.GetFibonacciParameter(LineStudyKey, 6) != NULL_VALUE
         };
     }
     else if (LineStudyType == "Fibonacci Timezones")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey)
         };
     }
     else if (LineStudyType == "Speed Line")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey)
         };
     }
     else if (LineStudyType == "Gann Fan")
     {
         infoGrid = new StudyInfo
         {
             ColorParameters =
                 ColorTranslator.FromOle(StockChartX1.GetTrendLineColor(LineStudyKey)),
             LineStyleParameters     = (Enums.LineStyle)StockChartX1.GetTrendLineStyle(LineStudyKey),
             LineThicknessParameters = StockChartX1.GetTrendLineThickness(LineStudyKey)
         };
     }
     pgrdStudy.SelectedObject = infoGrid;
     LoadDictionaryParameters();
     //pgrdStudy.AutoSize = true;
 }