/// <summary>Price and volume are going down after price rise.</summary> private bool volumeDeclineAfterPriceRise(List<Candle> candles) { const int MIN_CANDLES = 7; //Not enough data, can't reliably say if (candles.Count < MIN_CANDLES) return false; candles = candles.TakeLast(MIN_CANDLES).ToList(); //Minimum rise of a candle to be considered significant. TODO: no magic here! const double SIGNIFICANT_RISE = 3.0; //In first 4 candles there are at least 3 significant rises and no significant fall const int MIN_RISE_CANDLES = 3; int rises = 0; double prevClosePrice = -1.0; //(BUG?) hmm, that makes first candle automatic rise for (var c = 0; c < 4; c++) { if (candles[c].ClosingPrice > candles[c].OpeningPrice + PRICE_SIGNIFICANCE_LIMIT && //rise candles[c].ClosingPrice > prevClosePrice + SIGNIFICANT_RISE) { prevClosePrice = candles[c].ClosingPrice; rises++; } else if (candles[c].ClosingPrice < candles[c].OpeningPrice - PRICE_SIGNIFICANCE_LIMIT) return false; //fall, good bye } if (rises < MIN_RISE_CANDLES) return false; //5th candle if (candles[4].ClosingPrice + PRICE_SIGNIFICANCE_LIMIT > candles[4].OpeningPrice) return false; //Not fall //6th candle (before last) if (candles[5].ClosingPrice + PRICE_SIGNIFICANCE_LIMIT > candles[5].OpeningPrice || candles[5].Volume > candles[4].Volume) return false; //Not fall or volume still rising //Present candle, most recent trade decides return candles[6].ClosingPrice < candles[5].ClosingPrice; }
private bool isRising(List<Candle> candles) { const int MIN_CANDLES = 3; if (candles.Count < MIN_CANDLES) return false; candles = candles.TakeLast(MIN_CANDLES).ToList(); //Present candle is significant rise if (candles.Last().ClosingPrice > candles.Last().OpeningPrice + 3.0*PRICE_SIGNIFICANCE_LIMIT) return true; //Previous 2 candles were rises and latest price was rise too //TODO: maybe something more sofisticated return candles[0].ClosingPrice > candles[0].OpeningPrice + PRICE_SIGNIFICANCE_LIMIT && candles[1].ClosingPrice > candles[1].OpeningPrice + PRICE_SIGNIFICANCE_LIMIT && candles[1].ClosingPrice < candles.Last().ClosingPrice; //Most recent price decides }