private static bool IsTimeframesValid <TPeriod>(IEnumerable <Candle> candles, out Candle err) where TPeriod : IPeriod { var periodInstance = Activator.CreateInstance <TPeriod>(); err = default(Candle); for (int i = 0; i < candles.Count() - 1; i++) { var candleEndTime = periodInstance.NextTimestamp(candles.ElementAt(i).DateTime); if (candleEndTime > candles.ElementAt(i + 1).DateTime) { err = candles.ElementAt(i); return(false); } } return(true); }
public static bool IsBear(this Candle candle) => candle.Open - candle.Close < 0;
public static bool IsBull(this Candle candle) => candle.Open - candle.Close > 0;
public static decimal GetBody(this Candle candle) => Math.Abs(candle.Open - candle.Close);
public static decimal GetLowerShadow(this Candle candle) => candle.Open < candle.Close ? candle.Open - candle.Low : candle.Close - candle.Low;
public static decimal GetUpperShadow(this Candle candle) => candle.Open < candle.Close ? candle.High - candle.Close : candle.High - candle.Open;