UPDATE: MACD Divergence Indicator for Think or Swim

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: , ,

12 Responses to “UPDATE: MACD Divergence Indicator for Think or Swim”

  1. MACD Divergence Indicator for Think or Swim | Read the Prospectus Says:

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

  2. Stuart Says:

    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

  3. Multi-Divergence Indicator for Think or Swim: MACD, RSI, CCI, On Balance Volume and many more | Read the Prospectus Says:

    […] 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 […]

  4. William craun Says:

    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

  5. Prospectus Says:

    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.


  6. Victor Says:

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


  7. Prospectus Says:

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


  8. tony Says:

    Hi Prospectus, the MACD indicator looks like it’s doing what I was hoping it would. which is great!. Though it is plotting on exactly the $1.00 line and not on the actual price ticks. Can you help?

  9. tony Says:

    I was using the wrong thinkscript to do the plotting. I figured it out. Thanks!

  10. Jackie Kosse Says:

    Good content admin

  11. Jordan Ruhle Says:

    I donated. I don’t know if the email is automated or if i needed to let you know.

  12. Prospectus Says:

    I just sent you an email. Thank you!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: