Beispiel #1
0
        public Company[] Filter(Company[] companies)
        {
            List <Company> result = new List <Company>();

            foreach (var company in companies)
            {
                if (direction > 0)
                {
                    var donchian   = DonchianChannell.High(period, company.Chart);
                    var last       = company.Chart.Last().High;
                    var percentage = (donchian - last) / donchian;
                    if (last >= donchian || (percentage > 0 && percentage < this.percentage))
                    {
                        result.Add(company);
                    }
                }
                else
                {
                    var donchian   = DonchianChannell.Low(period, company.Chart);
                    var last       = company.Chart.Last().Low;
                    var percentage = (last - donchian) / last;
                    if (last <= donchian || (percentage > 0 && percentage < this.percentage))
                    {
                        result.Add(company);
                    }
                }
            }

            return(result.ToArray());
        }
        public void DonchianLowMiddleTest()
        {
            var candleList = new Candle[]
            {
                new Candle()
                {
                    Low = 2
                },
                new Candle()
                {
                    Low = 3
                },
                new Candle()
                {
                    Low = 3
                },
                new Candle()
                {
                    Low = 1
                },
                new Candle()
                {
                    Low = 3
                },
                new Candle()
                {
                    Low = 3
                },
                new Candle()
                {
                    Low = 3
                }
            };

            var lowValue = DonchianChannell.Low(3, candleList, 2);

            Assert.AreEqual(2, lowValue);
        }
        public void DonchianLowTest()
        {
            var candleList = new Candle[]
            {
                new Candle()
                {
                    Low = 3
                },
                new Candle()
                {
                    Low = 3
                },
                new Candle()
                {
                    Low = 3
                },
                new Candle()
                {
                    Low = 1
                },
                new Candle()
                {
                    Low = 3
                },
                new Candle()
                {
                    Low = 3
                },
                new Candle()
                {
                    Low = 3
                }
            };

            var lowValue = DonchianChannell.Low(5, candleList);

            Assert.AreEqual(1, lowValue);
        }