Ejemplo n.º 1
0
        public static Currency TradeyCalcs(Currency c)
        {
            var tcandles = new List <IOhlcv>();

            foreach (var item in c.Candles)
            {
                tcandles.Add(new TradyCandle()
                {
                    Open = item.Open, Close = item.Close, DateTime = FromUnixTime(item.CloseTime), Volume = item.Volume, High = item.High, Low = item.Low
                });
            }


            var comp = new SimpleMovingAverage(tcandles, 30);

            //sma - standard moving average
            var res  = comp.ComputeSma(30);
            var calc = res.LastOrDefault();

            if (calc != null && calc.Tick != null)
            {
                c.sma = Math.Round((decimal)calc.Tick, 4);
            }

            //sd - standard deviation
            res  = comp.ComputeSd(30);
            calc = res.LastOrDefault();
            if (calc != null && calc.Tick != null)
            {
                c.sd = Math.Round((decimal)calc.Tick, 4);
            }

            //smadif - standard moving average differential (i think)
            res  = comp.ComputeDiff(30);
            calc = res.LastOrDefault();
            if (calc != null && calc.Tick != null)
            {
                c.smaDiff = Math.Round((decimal)calc.Tick, 4);
            }

            //smadif - standard moving average differential (i think)
            res  = comp.ComputeRDiff(30);
            calc = res.LastOrDefault();
            if (calc != null && calc.Tick != null)
            {
                c.smaRDiff = Math.Round((decimal)calc.Tick, 4);
            }

            return(c);
        }