Пример #1
0
        public void AddCandleStick(Candlestick futureCandleStick)
        {
            var list = new List <Candlestick>();

            list.Add(futureCandleStick);
            list.AddRange(_candleSticks.Take(100));
            _candleSticks = list;
            rsi.AddCandleStick(futureCandleStick);
            var     sRsiList   = new List <decimal>();
            var     rsiLenList = rsi.rsi.Take(_shochRsiLength).ToList();
            var     maxRsi     = rsiLenList.Max();
            var     minRsi     = rsiLenList.Min();
            decimal shochrsi;

            if (maxRsi - minRsi != 0)
            {
                shochrsi = (rsi.Value - minRsi) / (maxRsi - minRsi);
            }
            else
            {
                shochrsi = 0;
            }

            sRsiList.Add(shochrsi);
            sRsiList.AddRange(stochRsi.Take(100));
            stochRsi = sRsiList;
            CalculateKandD();
        }
Пример #2
0
        public void Add(Candlestick futureCandleStick)
        {
            //kdb c = new kdb("localhost", 5000);
            List <Candlestick> list = new List <Candlestick>();

            list.Add(futureCandleStick);
            list.AddRange(_candleSticks);
            _candleSticks = list;
            foreach (KeyValuePair <int, Sma> keyValuePair in Sma)
            {
                keyValuePair.Value.AddCandleStick(futureCandleStick);
                //c.k($"insert[`MA](`{pair};\"Z\"$ \"{futureCandleStick.OpenDateTime:yyyy-MM-ddTHH:mm:ss:fffff}\"; `SMA; {keyValuePair.Key.ToString()}; \"f\"${keyValuePair.Value.Value})");
            }
            foreach (KeyValuePair <int, Ema> keyValuePair in Ema)
            {
                keyValuePair.Value.AddCandleStick(futureCandleStick);
                // c.k($"insert[`MA](`{pair};\"Z\"$ \"{futureCandleStick.OpenDateTime:yyyy-MM-ddTHH:mm:ss:fffff}\"; `EMA;{keyValuePair.Key.ToString()}; \"f\"${keyValuePair.Value.Value})");
            }
            foreach (KeyValuePair <int, Gsma> keyValuePair in Gsma)
            {
                keyValuePair.Value.AddCandleStick(futureCandleStick);
                //c.k($"insert[`MA](`{pair};\"Z\"$ \"{futureCandleStick.OpenDateTime:yyyy-MM-ddTHH:mm:ss:fffff}\"; `GSMA; {keyValuePair.Key.ToString()}; \"f\"${keyValuePair.Value.Value*10000000000})");
            }
            stochRsi.AddCandleStick(futureCandleStick);
            //c.k($"insert[`Oscillator](`{pair};\"Z\"$ \"{futureCandleStick.OpenDateTime:yyyy-MM-ddTHH:mm:ss:fffff}\"; `SRSI; \"f\"${ stochRsi.KValue};\"f\"${stochRsi.DValue})");
            rsi.AddCandleStick(futureCandleStick);
            //c.k($"insert[`Oscillator](`{pair};\"Z\"$ \"{futureCandleStick.OpenDateTime:yyyy-MM-ddTHH:mm:ss:fffff}\"; `RSI; \"f\"${ rsi.Value};0.0)");
            macd.AddCandleStick(futureCandleStick);
            //c.k($"insert[`Oscillator](`{pair};\"Z\"$ \"{futureCandleStick.OpenDateTime:yyyy-MM-ddTHH:mm:ss:fffff}\"; `MACD; \"f\"${ macd.MacdLine.First()*100000000};\"f\"${macd.SignalLine.First()*100000000})");
        }