Exemple #1
0
        private void initialize()
        {
            if (BuyOrders.Any())
            {
                CurrentBuyPrice = BuyOrders.MaxBy(order => order.Price).Price;
            }
            if (SellOrders.Any())
            {
                CurrentSellPrice = SellOrders.MinBy(order => order.Price).Price;
            }
            var high = new List <decimal>();
            var low  = new List <decimal>();

            if (!MarketHistory.Any())
            {
                return;
            }
            foreach (MarketHistoryAggregateEntry entry in MarketHistory)
            {
                high.Add(entry.HighPrice);
                low.Add(entry.LowPrice);
                if (high.Count > DonchianLength)
                {
                    high.RemoveAt(0);
                }
                if (low.Count > DonchianLength)
                {
                    low.RemoveAt(0);
                }
                if (high.Any())
                {
                    entry.DonchianHigh = high.Max();
                }
                if (low.Any())
                {
                    entry.DonchianLow = low.Min();
                }
                entry.DonchianCenter = (entry.DonchianHigh + entry.DonchianLow) / 2;
            }
        }