Exemplo n.º 1
0
        private void DrawOrUpdateVerticalLines(ChartTrendLine mainFan, Dictionary <double, ChartTrendLine> verticalLines)
        {
            var startBarIndex = mainFan.GetStartBarIndex(Chart.Bars, Chart.Symbol);
            var endBarIndex   = mainFan.GetEndBarIndex(Chart.Bars, Chart.Symbol);

            var barsNumber = mainFan.GetBarsNumber(Chart.Bars, Chart.Symbol);

            var rectangleEndTime = mainFan.GetEndTime();

            for (int i = 0; i < _settings.SideFanSettings.Length; i++)
            {
                var fanSettings = _settings.SideFanSettings[i];

                if (fanSettings.Percent < 0)
                {
                    continue;
                }

                var lineLevel = fanSettings.Percent * barsNumber;

                var barIndex = mainFan.Time1 > mainFan.Time2 ? startBarIndex + lineLevel : endBarIndex - lineLevel;

                var time = Chart.Bars.GetOpenTime(barIndex, Chart.Symbol);

                if (time > rectangleEndTime)
                {
                    time = rectangleEndTime;
                }

                ChartTrendLine line;

                if (verticalLines.TryGetValue(fanSettings.Percent, out line))
                {
                    line.Time1 = time;
                    line.Time2 = time;

                    line.Y1 = mainFan.Y1;
                    line.Y2 = mainFan.Y2;
                }
                else if (_settings.ShowTimeLevels)
                {
                    var objectName = GetObjectName(string.Format("VerticalLine_{0}", fanSettings.Percent.ToString(CultureInfo.InvariantCulture)));

                    line = Chart.DrawTrendLine(objectName, time, mainFan.Y1, time, mainFan.Y2, _settings.TimeLevelsColor, _settings.TimeLevelsThickness, _settings.TimeLevelsStyle);

                    line.IsInteractive = true;
                    line.IsLocked      = true;

                    verticalLines.Add(fanSettings.Percent, line);
                }
            }
        }
Exemplo n.º 2
0
        protected virtual void UpdateSideFans(ChartTrendLine mainFan, Dictionary <double, ChartTrendLine> sideFans)
        {
            var startBarIndex = mainFan.GetStartBarIndex(Chart.Bars, Chart.Symbol);
            var endBarIndex   = mainFan.GetEndBarIndex(Chart.Bars, Chart.Symbol);

            var barsNumber = mainFan.GetBarsNumber(Chart.Bars, Chart.Symbol);

            var mainFanPriceDelta = mainFan.GetPriceDelta();

            for (var iFan = 0; iFan < SideFanSettings.Length; iFan++)
            {
                var fanSettings = SideFanSettings[iFan];

                double   y2;
                DateTime time2;

                if (fanSettings.Percent < 0)
                {
                    var yAmount = mainFanPriceDelta * Math.Abs(fanSettings.Percent);

                    y2 = mainFan.Y2 > mainFan.Y1 ? mainFan.Y2 - yAmount : mainFan.Y2 + yAmount;

                    time2 = mainFan.Time2;
                }
                else
                {
                    y2 = mainFan.Y2;

                    var barsPercent = barsNumber * fanSettings.Percent;

                    var barIndex = mainFan.Time2 > mainFan.Time1 ? endBarIndex - barsPercent : startBarIndex + barsPercent;

                    time2 = Chart.Bars.GetOpenTime(barIndex, Chart.Symbol);
                }

                ChartTrendLine fanLine;

                if (!sideFans.TryGetValue(fanSettings.Percent, out fanLine))
                {
                    continue;
                }

                fanLine.Time1 = mainFan.Time1;
                fanLine.Time2 = time2;

                fanLine.Y1 = mainFan.Y1;
                fanLine.Y2 = y2;
            }
        }
Exemplo n.º 3
0
        protected virtual void DrawSideFans(ChartTrendLine mainFan)
        {
            var startBarIndex = mainFan.GetStartBarIndex(Chart.Bars, Chart.Symbol);
            var endBarIndex   = mainFan.GetEndBarIndex(Chart.Bars, Chart.Symbol);

            var barsNumber = mainFan.GetBarsNumber(Chart.Bars, Chart.Symbol);

            var mainFanPriceDelta = mainFan.GetPriceDelta();

            for (var iFan = 0; iFan < SideFanSettings.Length; iFan++)
            {
                var fanSettings = SideFanSettings[iFan];

                double   y2;
                DateTime time2;

                if (fanSettings.Percent < 0)
                {
                    var yAmount = mainFanPriceDelta * Math.Abs(fanSettings.Percent);

                    y2 = mainFan.Y2 > mainFan.Y1 ? mainFan.Y2 - yAmount : mainFan.Y2 + yAmount;

                    time2 = mainFan.Time2;
                }
                else
                {
                    y2 = mainFan.Y2;

                    var barsPercent = barsNumber * fanSettings.Percent;

                    var barIndex = mainFan.Time2 > mainFan.Time1 ? endBarIndex - barsPercent : startBarIndex + barsPercent;

                    time2 = Chart.Bars.GetOpenTime(barIndex, Chart.Symbol);
                }

                var objectName = GetObjectName(string.Format("SideFan_{0}", fanSettings.Percent));

                var trendLine = Chart.DrawTrendLine(objectName, mainFan.Time1, mainFan.Y1, time2, y2, fanSettings.Color, fanSettings.Thickness, fanSettings.Style);

                trendLine.IsInteractive    = true;
                trendLine.IsLocked         = true;
                trendLine.ExtendToInfinity = true;

                SideFanLines[fanSettings.Percent] = trendLine;
            }
        }