void BittrexOHLC(string pair, bool display = true) { // TODO: CONVERT THIS TO USE BINANCE (or other) SOURCE FOR OHLC CANDLESTICK DATA var ohlc = bittrex.GetOHLC(pair, 1); // OHLC 1-MINUTE BARS if (ohlc == null) { return; // if an exception occurs, skip this iteration } long last = ohlc.Last; //ohlc.WriteToFile(Folders.crypto_path(string.Format("Kraken.{0}.DF.csv", pair))); double MACD, signal, hist; foreach (var bar in ohlc.Pairs.Values.First()) { if (m_bars.Count == 0 || bar.Time > m_bars.Last().Time) // only add bars whose Time is greater than the last added bar { m_bars.Add(bar); decimal o = bar.Open; decimal h = bar.High; decimal l = bar.Low; decimal c = bar.Close; int time = bar.Time; decimal volume = bar.Volume; decimal vwap = bar.Vwap; int count = bar.Count; if (display) { cout(bar.ToString()); } m_macd.ReceiveTick((double)c); if (m_macd.isPrimed()) // indicator is "primed" when it has enough data to calculate values { m_macd.Value(out MACD, out signal, out hist); // calculate MACD values if (display) { cout("---MACD:{0} signal:{1} hist:{2}", MACD, signal, hist); // display the values } m_indicator.Add(new double[] { MACD, signal, hist }); // add the values to the m_indicator List if (m_pos > 0 && hist < 0) // CHECK TO SEE IF WE CROSSED pos-to-neg or neg-to-pos { TradeSell(pair); // long position and histMACD negative = SELL } else if (m_pos < 0 && hist > 0) { TradeBuy(pair); // short position and histMACD positive = BUY } } } } }