This indicator has been updated! See the new post here.

This has been a long time in coming. My family life has been in upheaval for a couple years now. I finally had a bit of time so I wanted to get this done. Thanks for staying with me.

Many people have asked for a version of the MACD Divergence Indicator that can run in a scan. The old one I had ran on recursive logic and so wasn’t supported in scans. This new one uses a different philosophy that runs in real time. Before I would use my Swing Points and check the value of the MACD against them. Higher swing highs and lower corresponding values of MACD on those bars would signal a bearish divergence. Now I am using Linear Regression slopes to compare divergences. Here’s the theory of how it works:

A linear regression is a way to fit a straight line through some data such that you get the least amount of average distance from the line. If the slope of the linear regression is up, then values are generally trending upward over the set of data you put in. If the slope is negative, then the values trend downward.

So I take a linear regression of price, then get the slope of the LR, and I also take a linear regression of the standard MACD indicator and get that slope. When the price slope is positive and the MACD slope is negative, we have a bearish MACD divergence. If price slope is negative and MACD slope is positive, we have a bullish divergence. If price slope and MACD slope are the same, we have a trend continuation (up/up or down/down). This chart shows this theory in action:

Here’s what my indicator actually looks like. The small arrows are short term divergences, the larger arrows are the long term divergences. The short and long timeframes are inputs, so you can set them at whatever you want. This chart uses 20 and 50 as the inputs, but you can experiment with what works best for what you are trading:

As with all divergences, just because it is there doesn’t mean that the trend must reverse. Sometimes divergences can go on for a long time. This information is good to give you a sense that a trend might reverse, and you can plan your own entry and stop accordingly.

Now, to set set up a custom scan, you follow the instructions in these pictures:

Then when your scan runs, you will get flagged if the divergence you asked for is currently found.

This indicator is for blog donors only. You can find it on my google site under Released Thinkscript Studies down in the Donors Only section.

Tags: divergence, macd, Thinkscript

December 10, 2014 at 9:11 pm

[…] This indicator has been updated! See the new post here. […]

December 11, 2014 at 1:24 pm

Hello Mr. “prospectus” nice to hear from you again, happy you did not give up on us.

Great to have a new version ,It would defiantly make life easier.

Was wondering how to display the arrows on a chart, as appears in your email.

I thought second zip would not be a Indicator but an upper study , apparently both are the same .

Please, help me display it on charts ?

best regards Stuart

January 15, 2015 at 2:27 am

[…] study. The new Multi-divergence script uses slopes of linear regression lines just like in the new MACD divergence indicator. This script supersedes all the other divergence scripts. The difference is now it can perform a […]

September 19, 2016 at 9:04 am

yes i got the indicator installed and set like you have (20 50) but there are hundreds of arrows that its meaningless to me. What am i doing wrong I assume the lo number 20 is 20 days for short term and 50 is 50 days for longer term

September 19, 2016 at 9:25 am

The arrows are not defined entry signals. The arrows are showing you when there is a divergence between price and the underlying indicator. Divergences flag when conditions are ripe for reversal, but you need your own entry criteria for exact timing. If you want fewer arrows, you can just use one timeframe (20,20) and then you don’t have overlapping long and short term divergence plots, just the one.

I kind of regret choosing arrows for the signal plot. I liked arrows because they could show the direction of divergence (bullish, bearish), but they seem to be more suited for taking action.

>

January 5, 2017 at 9:39 pm

I made a donation last night. Kindly send me the password for download.

Thanks

January 6, 2017 at 9:27 am

I did, check your spam folders. I’m resending now

>