1. How to scan for stocks with a divergence between price and MACD?
  2. How to scan for stocks with a divergence between price and volume?

asked Aug 21 '11 at 22:15

ekwong's gravatar image

8.3k 13039

closed Oct 22 '11 at 12:21

Hi ekwong,I wonder if you could specify the divergences you are looking for. For volume/price, are you referring to moving average of volume, OBV, accumulation/distribution or something else. For price, what value(s) do you want to use, the close, a moving average or something else? Similar specifics for MACD.

(Aug 22 '11 at 11:33) markd markd's gravatar image

Hi ekwong,

RE: MACD Divergences

Here's a scan that I use which looks for Bullish Divergences. The scan looks for a lower stock price over the last ten days compared to the previous 50 days, then looks for a higher MACD (line and histogram) over the same period.

Change the ">" to "<" and vice versa, "daily min" to "daily max" and "daily low" to "daily high" to scan for Bearish Divergences.

You can also change daily to whatever time period you want to scan for, and the 10 and 50 to any number of periods you want to look at.

You can omit either the line or histogram portion of the MACD scan if you don't want both. Personally, I think the divergence is more meaningful if you've got both.

The scan can probably be modified to look for volume divergences as well, although I've never tried it.

[daily min(10,daily low) < 10 days ago daily min(50,daily low)] and [daily min(10,daily macd hist(12,26,9)) > 10 days ago daily min(50,macd hist(12,26,9))] and [daily min(10,MACD Line (12,26,9)) > 10 days ago daily min(50,MACD Line (12,26,9))]

Copy and paste the above code into the advance scan builder, along with any filters you want to add. Hope this helps.


answered Aug 22 '11 at 14:43

CasualTrader's gravatar image

635 39

edited Nov 04 '13 at 01:01

I tried your solution -- there were a lot of close calls, but it was an excellent start. Thanks for your suggestion.

(Aug 24 '11 at 23:38) ekwong ekwong's gravatar image

Pretty neat!

(Dec 22 '11 at 14:50) ksquared ksquared's gravatar image

Bearish divergence:

[daily max(10,daily high) > 10 days ago daily max(50,daily high)] and 
[daily max(10,daily macd hist(12,26,9)) < 10 days ago daily max(50,macd hist(12,26,9))] and 
[daily max(10,MACD Line (12,26,9)) < 10 days ago daily min(50,MACD Line (12,26,9))]
(Nov 03 '13 at 19:39) ekwong ekwong's gravatar image

Another approach would be to use the slope function. The following scan just returned 54 symbols. Reverse the "<' and ">' to scan for the opposite divergence.

[type = stock] and [country = us] and

[daily sma(20,daily volume) > 200000] and

[daily sma(60,daily close) > 10] and

// slope of the MACD signal positive

[daily slope(20,daily macd signal(12,26,9)) > 0] and

// slope of the price negative

[daily slope(20,daily close) < 0]


answered Oct 19 '11 at 15:05

markk's gravatar image

3.2k 711

edited Oct 19 '11 at 15:14

I just ran this same code for several days:

[type = stock] and [[exchange is NYSE] or [exchange is AMEX] or [exchange is NASDAQ]] and [daily sma(20,daily volume) > 200000] and [Close > 10] and [daily slope(20,daily macd signal(12,26,9)) > 0] and [daily slope(20,daily close) < 0]

And I am getting hundreds and hundreds of results. I just ran one for September 30th: 879 results. Not atypical, and many of them don't look like anything like a classic MACD positive divergence.

(Dec 11 '11 at 18:20) chasfh chasfh's gravatar image

I ran it today against sp500 and sp600 and got under 10 hits for both and they all showed divergence. Maybe not all "classic divergence" but I think the author meant to suggest a possibly helpful approach, not the last word, and I think he did that.

(Dec 12 '11 at 21:23) markd markd's gravatar image

When you get too many results, you need to tighten up the criteria, say try volume > 500K or add something like close > sma50.

(Dec 13 '11 at 15:56) markk markk's gravatar image

Here is a solution for bullish divergences between price and the MACD Histogram.

I originally included the "Lower Lows / Higher Lows" part of the code, but now I have that switched off (with the // sign in front), and instead prefer a semi-automatic approach. Feel free to switch it back on and experiment.

The configuration below will output stocks that are in the first uptick within a trough in the MACD histogram. It can also be tuned to output only significant divergences. That's the automatic part.

The manual part is to look at the charts of each result and see if the current trough is part of a divergence or not. The fastest way to do this is to copy and paste the list of output stocks into the Candle Glance feature, and select MACD as the indicator (only one is allowed in Candle Glance). You can see the good ones in seconds this way.

This semi-automatic approach will give you a handful of tradeable divergences every day, with only a few seconds of work. (This is the reverse of Elder's semi-automatic approach, which involves automatically finding the 1st trough and manually looking for the 2nd)


[type = stock] AND [Daily SMA(20,Daily Volume) > 500000] and [close > 2]

// Looks for Lower Lows in price (This needs tweaking still)

//AND [min(20,close) <= min(60, close)]

//AND [EMA(10) < EMA(65)]

// Looks for HIGHER lows in MACD HIST (This also needs tweaking)

// AND [min(20,macd hist(12,26,9)) > min(60,macd hist(12,26,9))]

// Looks for MACDH bottoming and uptick in DAILY bars

AND [macd line(12,26,9) < 0]

AND [macd hist(12,26,9) < 0]

AND [macd hist(12,26,9) > yesterday's macd hist(12,26,9)]

AND [yesterday's macd hist(12,26,9) < 2 days ago macd hist(12,26,9)]

// Looks for a more significant divergence. Tweak the parameters to filter more or less.

AND [yesterday's macd hist(12,26,9) > 0.6 * min(40, macd hist(12,26,9))]


answered Nov 07 '13 at 02:24

Them's gravatar image

256 18

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Aug 21 '11 at 22:15

Seen: 4,942 times

Last updated: Nov 07 '13 at 02:24