// Return +1 (BUY), -1 (SELL), or 0 (NO TRADE) int CheckIndicator(iMACD macd, bool displayIndicator = true) { if (!macd.isPrimed()) { return(0); // indicator is not primed, so return zero (NO TRADE) } // indicator is "primed" when it has enough data to calculate values double MACD, signal, hist; 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 if (displayIndicator) { var ticker = m_exch.GetTicker(m_pair); cout("{0}>---MACD:{1:0.00000000}--- [{2}] slow:{3:0.00000000} fast:{4:0.00000000} {5} x {6} -- {7} x {8} (b/a={9}) vol={10}", PairId, hist, DateTime.Now.ToShortTimeString(), MACD, signal, ticker.BidSize, ticker.Bid, ticker.Ask, ticker.AskSize, ticker.BidAskSpread, ticker.Volume); // display only the histMACD value } 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 if (hist < 0) // CHECK TO SEE IF WE CROSSED pos-to-neg or neg-to-pos { //if (isCompleteBar) TradeSell(); // long position and histMACD negative = SELL return(-1); } //else if (m_pos < 0 && hist > 0) else if (hist > 0) { //if (isCompleteBar) TradeBuy(); // short position and histMACD positive = BUY return(+1); } else { return(0); } }