implement macd query