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.