/// <summary> /// Looks for white marubozus. /// </summary> private void LookForWhiteMarubozus(CandlestickAnalyzer candlestick, List<StockDaily> dailies, int index, DateTime date) { if (candlestick.IsWhiteMarubozu()) { var peekIndex = index + 1; var lumens = 0; while (peekIndex < dailies.Count) { if (dailies[peekIndex].LowPrice > candlestick.Low) { lumens++; } else { break; } if (peekIndex - index >= 20) { break; } peekIndex++; } this.whiteMarubozuNumOccurences++; this.whiteMarubozuTotalLumens += lumens; this.whiteMarubozuLumenRating = Convert.ToInt32(this.whiteMarubozuTotalLumens / this.whiteMarubozuNumOccurences); Console.WriteLine("White Marubozus -- Symbol=" + candlestick.TickerSymbol + "; Date=" + date.ToShortDateString() + "; Lumens=" + lumens + "; Rating=" + this.whiteMarubozuLumenRating); } }
/// <summary> /// Looks for white marubozus. /// </summary> private void LookForWhiteMarubozus(CandlestickAnalyzer candlestick, List<StockDaily> dailies, int index, DateTime date) { if (candlestick.IsWhiteMarubozu()) { var peekIndex = index + 1; var lumens = 0; while (peekIndex < dailies.Count) { if (dailies[peekIndex].LowPrice > candlestick.Low) { lumens++; } else { break; } if (peekIndex - index >= 100) { break; } peekIndex++; } this.whiteMarubozuNumOccurences++; this.whiteMarubozuTotalLumens += lumens; this.whiteMarubozuLumenRating = Convert.ToInt32(this.whiteMarubozuTotalLumens / this.whiteMarubozuNumOccurences); Console.WriteLine("White Marubozus -- Symbol=" + candlestick.TickerSymbol + "; Date=" + date.ToShortDateString() + "; Lumens=" + lumens + "; Rating=" + this.whiteMarubozuLumenRating); using (var context = new StockScreenerEntities()) { if (context.CandlesticksToStocks.Count(entry => entry.CandlestickId == PatternIds.WhiteMarubozu && entry.Ticker.Equals(candlestick.TickerSymbol)) > 0) { var candlestickToStock = context.CandlesticksToStocks.First( entry => entry.CandlestickId == PatternIds.WhiteMarubozu && entry.Ticker.Equals(candlestick.TickerSymbol)); var newLumenRating = ((candlestickToStock.LumenRating * candlestickToStock.NumOccurrences) + lumens) / ++candlestickToStock.NumOccurrences; candlestickToStock.LumenRating = newLumenRating; } else { context.CandlesticksToStocks.AddObject(new CandlesticksToStock { CandlestickId = PatternIds.WhiteMarubozu, Exchange = candlestick.Exchange, Ticker = candlestick.TickerSymbol, LumenRating = lumens, NumOccurrences = 1 }); } context.SaveChanges(); } } }