funwiththinkscript – MACD Divergence: Fully Automatic
Identifying a MACD divergence has never been easier. Get the ONLY indicator for ThinkorSwim that actually draws a MACD divergence.
money well spent for my type of trading!
really enjoying your macd divergence indicator! in times past there has been times i got frustrated expecting a divergence and it not yet play out (ie march ’16). but using yours based off Elder’s definition of breaking the zero line really has made a difference for me when trying to base my posture expectations. money well spent for my type of trading! thanks again for your excellent indicators.
Note: While not mentioned in the review above, the screenshot provided includes both the Mechanical MACD Divergence (yellow lines) and the Automatic Trend Lines (gray lines).
Very pleased with the above script [Mechanical MACD Divergence], looks great for my type of trading. I have been using it on the TOS platform on my P.C. [and] on the TOS mobile platform for my IPad. Once again thank your for a great script, I to, know of no one else who has this script so it is a huge achievement.
The scan on the desktop P.C. TOS platform is also working well, I have it set up so it runs the scan on a watch list live, I.e. Daily, Hourly and 15min. so I can visually see if an alert is triggered even if I’m not watching a symbol on my default watchlist of symbols on the charts.
This indicator is one that I have wanted to create since I very first began learning ThinkScript. Different divergence indicators do exist, but NONE of them have lines drawn on them in the manner that is always shown in technical analysis books. Those are always left up to the user to manually spot and draw in by hand.
I did a LOT of searching for a script that did it automatically and have never found anything. I even looked for help on how to draw the trend-lines, but, again, never came up with anything useful. It wasn’t until I created my Basic Market Structure script that I really figured out what I needed to know to draw the lines. The knowledge that I gained from writing that script allowed me to figure out how to do my auto-trend lines. That one was really complicated, but I was able to build from that one to the near-term divergence lines in the advanced market forecast indicator.
As soon as I finished that one, I knew that I, finally, had the required skills to create a proper MACD divergence study. One that NO ONE else has.
Without further ado, I present the Mechanical MACD Divergence indicator.
In researching divergences online, I came across several different methodologies for determining them. In the end, I settled on the classic MACD divergence as detailed by Alexander Elder in “The New Trading For a Living.” According to him, divergences between MACD-Histogram and prices are infrequent, but they give some of the most powerful signals.
A classical bullish divergence occurs in a down-trend when prices and the oscillator both fall to a new low, rally, with the oscillator rising above its zero line, then both fall again. This time, prices drop to a lower low, but an oscillator traces a higher bottom during its previous decline.
According to Alexander, the breaking of the centerline between two indicator bottoms is an absolute must for a true divergence. MACD-Histogram has to cross above the zero line before skidding to its second bottom. If there is no crossover, there is no divergence.
A classical bearish divergence occurs in an up-trend when prices reach a new high and then pull back, with an oscillator dropping below its zero line. Prices stabilize and rally to a higher high, but an oscillator reaches a lower peak than it did on a previous rally.
Bullish and bearish divergences are automatically plotted following the rules outlined by Alexander Elder. Bullish divergences are shown in yellow while bearish divergences are shown in orange. The colors may be changed from within the script settings panel along with the MACD parameters and whether or not to show signal arrows.