Example #1
0
        private List <Trendline> GetBottomLines()
        {
            CandleData       data       = DataManager.GetCandleDataForPairAndInterval(coinPair, interval);
            decimal          divergence = Helper.GetDivergence(coinPair, interval);
            List <Trendline> trendlines = new List <Trendline>();

            for (int i = data.candles.Count - this.candleNumber; i < data.candles.Count - 3; i++)
            {
                for (int j = i + 1; j < data.candles.Count - 2; j++)
                {
                    decimal movement = GetMovement(i, j, data.candles[i].Low, data.candles[j].Low);
                    decimal n        = GetN(i, j, data.candles[i].Low, data.candles[j].Low);

                    Trendline tl = new Trendline(movement, n, i, interval, new List <TrendPoint>(), data.candles.Count);
                    tl.linePoints.Add(new TrendPoint(data.candles[i].Low, i));
                    tl.linePoints.Add(new TrendPoint(data.candles[j].Low, j));

                    for (int k = j + 1; k < data.candles.Count - 1; k++)
                    {
                        if (Math.Abs((movement * k + n) - data.candles[k].Low) <= divergence)
                        {
                            tl.linePoints.Add(new TrendPoint(data.candles[k].Low, k));
                        }
                    }
                    if (tl.linePoints.Count > 2)
                    {
                        trendlines.Add(tl);
                    }
                }
            }
            return(RemoveBadTrendlinesBottom(data, trendlines, divergence));
        }
Example #2
0
        private List <Trendline> GetTopLines()
        {
            var data       = DataManager.GetCandleDataForPairAndInterval(coinPair, interval);
            var divergence = Helper.GetDivergence(coinPair, interval);
            List <Trendline> trendlines = new List <Trendline>();

            for (var i = data.candles.Count - this.candleNumber; i < data.candles.Count - 3; i++)
            {
                for (var j = i + 1; j < data.candles.Count - 2; j++)
                {
                    var m = GetMovement(i, j, data.candles[i].High, data.candles[j].High);
                    var n = GetN(i, j, data.candles[i].High, data.candles[j].High);

                    Trendline tl = new Trendline(m, n, i, interval, new List <TrendPoint>(), data.candles.Count);
                    tl.linePoints.Add(new TrendPoint(data.candles[i].High, i));
                    tl.linePoints.Add(new TrendPoint(data.candles[j].High, j));

                    for (int k = j + 1; k < data.candles.Count - 1; k++)
                    {
                        if (Math.Abs((m * k + n) - data.candles[k].High) <= divergence)
                        {
                            tl.linePoints.Add(new TrendPoint(data.candles[k].High, k));
                        }
                    }
                    if (tl.linePoints.Count > 2)
                    {
                        trendlines.Add(tl);
                    }
                }
            }
            return(RemoveBadTrendlinesTop(data, trendlines, divergence));
        }
Example #3
0
 /**
  * Returns the Trend from the Trendline start to the current Price in percent
  */
 private static decimal GetTrenddirection(string coinPair, Trendline tl)
 {
     return(tl.linePoints.Count > 0 ? (100 * DataManager.GetPrice(coinPair)) / tl.linePoints[0].value : 0);
 }