Exemplo n.º 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));
        }
Exemplo n.º 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;
        }
Exemplo n.º 3
0
 public static double GetEndBarIndex(this ChartRectangle rectangle, Bars bars, Symbol symbol)
 {
     return(bars.GetBarIndex(rectangle.GetEndTime(), symbol));
 }
Exemplo n.º 4
0
 public static double GetEndBarIndex(this ChartTrendLine line, Bars bars, Symbol symbol)
 {
     return(bars.GetBarIndex(line.GetEndTime(), symbol));
 }