Example #1
0
        public static double GetBarsNumber(this ChartRectangle rectangle, Bars bars, Symbol symbol)
        {
            var startX = rectangle.GetStartTime();
            var endX   = rectangle.GetEndTime();

            var startBarIndex = bars.GetBarIndex(startX, symbol);
            var endBarIndex   = bars.GetBarIndex(endX, symbol);

            return(Math.Round(endBarIndex - startBarIndex, 2));
        }
Example #2
0
        public static void RefelectOnOtherLine(this ChartTrendLine line, ChartTrendLine otherLine, Bars bars, Symbol symbol)
        {
            var onePercentFirstBarIndex = bars.GetBarIndex(otherLine.Time1, symbol);

            var zeroLineBarsDelta  = line.GetBarsNumber(bars, symbol);
            var zeroLinePriceDelta = line.GetPriceDelta();

            var zeroLineSlope = line.GetSlope();

            double secondBarIndex, secondPrice;

            if (line.Time1 < line.Time2)
            {
                secondBarIndex = onePercentFirstBarIndex + zeroLineBarsDelta;
                secondPrice    = zeroLineSlope > 0 ? otherLine.Y1 + zeroLinePriceDelta : otherLine.Y1 - zeroLinePriceDelta;
            }
            else
            {
                secondBarIndex = onePercentFirstBarIndex - zeroLineBarsDelta;
                secondPrice    = zeroLineSlope > 0 ? otherLine.Y1 - zeroLinePriceDelta : otherLine.Y1 + zeroLinePriceDelta;
            }

            otherLine.Time2 = bars.GetOpenTime(secondBarIndex, symbol);
            otherLine.Y2    = secondPrice;
        }
Example #3
0
 public static double GetEndBarIndex(this ChartRectangle rectangle, Bars bars, Symbol symbol)
 {
     return(bars.GetBarIndex(rectangle.GetEndTime(), symbol));
 }
Example #4
0
 public static double GetEndBarIndex(this ChartTrendLine line, Bars bars, Symbol symbol)
 {
     return(bars.GetBarIndex(line.GetEndTime(), symbol));
 }