예제 #1
0
        public static IndicatorResults <decimal> GetCandlesEMA(List <XCandle> candles, int periodEMA)
        {
            var results = new IndicatorResults <decimal>();
            var ema     = new iEMA(periodEMA);

            foreach (var c in candles)
            {
                //var timeString = c.Timestamp.ToString("yyyy-MM-dd HH:mm:ss");
                //Console.WriteLine("{0} {1} {2} o:{3} h:{4} l:{5} c:{6} vol:{7} period:{8} wavg:{9}", timeString, c.ExchangeName, c.Name, c.OpenPrice, c.HighPrice, c.LowPrice, c.ClosePrice, c.BaseVolume, c.PeriodSeconds, c.WeightedAverage);
                ema.ReceiveTick(c.ClosePrice);
                if (ema.IsPrimed)
                {
                    results.Add(c, ema.Value);
                }
            }
            return(results);
        }
예제 #2
0
        public static IndicatorResults <ResultMACD> GetCandlesMACD(List <XCandle> candles, int periodFastEMA, int periodSlowEMA, int periodSignalEMA)
        {
            var results = new IndicatorResults <ResultMACD>();
            var macd    = new iMACD(periodFastEMA, periodSlowEMA, periodSignalEMA);

            foreach (var c in candles)
            {
                //var timeString = c.Timestamp.ToString("yyyy-MM-dd HH:mm:ss");
                //Console.WriteLine("{0} {1} {2} o:{3} h:{4} l:{5} c:{6} vol:{7} period:{8} wavg:{9}", timeString, c.ExchangeName, c.Name, c.OpenPrice, c.HighPrice, c.LowPrice, c.ClosePrice, c.BaseVolume, c.PeriodSeconds, c.WeightedAverage);
                macd.ReceiveTick(c.ClosePrice);
                if (macd.IsPrimed)
                {
                    results.Add(c, macd.ResultValue());
                }
            }
            return(results);
        }