示例#1
0
        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);
        }
示例#2
0
 public static bool IsBear(this Candle candle) => candle.Open - candle.Close < 0;
示例#3
0
 public static bool IsBull(this Candle candle) => candle.Open - candle.Close > 0;
示例#4
0
 public static decimal GetBody(this Candle candle) => Math.Abs(candle.Open - candle.Close);
示例#5
0
 public static decimal GetLowerShadow(this Candle candle) => candle.Open < candle.Close ? candle.Open - candle.Low : candle.Close - candle.Low;
示例#6
0
 public static decimal GetUpperShadow(this Candle candle) => candle.Open < candle.Close ? candle.High - candle.Close : candle.High - candle.Open;