Exemplo n.º 1
0
        private void DrawOrUpdateExtendedSideLines(ChartTrendLine mainFanLine, ref ChartTrendLine horizontalLine, ref ChartTrendLine verticalLine)
        {
            if (mainFanLine == null)
            {
                return;
            }

            var time1 = mainFanLine.Time1;
            var time2 = mainFanLine.Time2;

            var y1 = mainFanLine.Y1;
            var y2 = mainFanLine.Y2;

            var timeDelta = mainFanLine.GetTimeDelta();

            var horizontalLineTime2 = time2 > time1?time2.Add(timeDelta) : time2.Add(-timeDelta);

            if (horizontalLine == null)
            {
                var name = GetObjectName("HorizontalExtendedLine");

                horizontalLine = Chart.DrawTrendLine(name, time1, y1, horizontalLineTime2, y1, _settings.ExtendedLinesColor, _settings.ExtendedLinesThickness, _settings.ExtendedLinesStyle);

                horizontalLine.IsInteractive    = true;
                horizontalLine.IsLocked         = true;
                horizontalLine.ExtendToInfinity = true;
            }
            else
            {
                horizontalLine.Time1 = time1;
                horizontalLine.Time2 = horizontalLineTime2;
                horizontalLine.Y1    = y1;
                horizontalLine.Y2    = y1;
            }

            var priceDelta = mainFanLine.GetPriceDelta();

            var verticalLineY2 = y2 > y1 ? y2 + priceDelta : y2 - priceDelta;

            if (verticalLine == null)
            {
                var name = GetObjectName("VerticalExtendedLine");

                verticalLine = Chart.DrawTrendLine(name, time1, y1, time1, verticalLineY2, _settings.ExtendedLinesColor, _settings.ExtendedLinesThickness, _settings.ExtendedLinesStyle);

                verticalLine.IsInteractive    = true;
                verticalLine.IsLocked         = true;
                verticalLine.ExtendToInfinity = true;
            }
            else
            {
                verticalLine.Time1 = time1;
                verticalLine.Time2 = time1;
                verticalLine.Y1    = y1;
                verticalLine.Y2    = verticalLineY2;
            }
        }