karlwancl / Trady

Trady is a handy library for computing technical indicators, and it targets to be an automated trading system that provides stock data feeding, indicator computing, strategy building and automatic trading. It is built based on .NET Standard 2.0.
https://lppkarl.github.io/Trady
Apache License 2.0
545 stars 185 forks source link

How to correctly call and compute indicators #115

Closed alavna closed 4 years ago

alavna commented 4 years ago

Hi. I am getting candles from Binance like this:

   public class BinanceKline
    {
        public BinanceKline();
        public DateTime OpenTime { get; set; }
        public decimal Open { get; set; }
        public decimal High { get; set; }
        public decimal Low { get; set; }
        public decimal Close { get; set; }
        public decimal Volume { get; set; }
        public DateTime CloseTime { get; set; }
        public decimal QuoteAssetVolume { get; set; }
        public int TradeCount { get; set; }
        public decimal TakerBuyBaseAssetVolume { get; set; }
        public decimal TakerBuyQuoteAssetVolume { get; set; }
    }

Then I create new Trady Candles :

        public static List<Candle> ConvertToTradyCandles(List<BinanceKline> kline)
        {
            List<Candle> result = new List<Candle>();
            foreach (var item in kline)
            {
                var TradyCandle = new Candle(item.OpenTime, item.Open, item.High, item.Low, item.Close, item.Volume);
                result.Add(TradyCandle);
            }
            return result;
        }

Then I use the converted candles to call trady indicator fucntions by in two ways:

             var converted = ConvertToTradyCandles(klines);

            var rsi = converted.Rsi(100, 1, 30);
            var sma = converted.Sma(200, 1, 100);
            var anotherway= new SimpleMovingAverage(c, 100)[3]

but I am getting null tick from all indicators. Is it something to do with DateTimeOffset? the function for binance time that I use to get the candles is GetServertime() and returns a Datetime with kind of UTC.

Thanks

tisawe commented 4 years ago

Were you able to solve the issue?