Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Divergence between Price and MACD Histogram Topic Rating:
Previous Topic · Next Topic Watch this topic · Print this topic ·
Al_Gorithm
Posted : Thursday, July 6, 2017 5:08:10 PM

Registered User
Joined: 6/30/2017
Posts: 1,227

Bruce,

Is there a "best" way to scan for divergences between Price and MACD Histogram?

Even though I'm no longer AlexElder, I still like to trade one of his favorite setups, when price and momentum diverge :)

I'm guessing this has been done. Just point the way...

Al_Gorithm
Posted : Thursday, July 6, 2017 5:13:53 PM

Registered User
Joined: 6/30/2017
Posts: 1,227

I'm flashing back to an old webinar where Julia used Moving Up Smart and Moving Down Smart. I guess that's one way. Any others?

traderlady
Posted : Thursday, July 6, 2017 11:14:24 PM
Registered User
Joined: 10/7/2004
Posts: 1,178

UnclePennybags,  try the underlined Search in the upper right.  To find a reference to Julia O answering a question about Price and MACD divergences, search for this phase:  "my approach is to plot Price History as well as a MACD"

There may be other references as well, but I just initially seached for "Julia" and found this one reference.

 

Bruce_L
Posted : Friday, July 7, 2017 9:57:38 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

I use the moving up vs moving down technique. I might check for both the net change and linear regression slope to be going in the same direction (for an individual indicator and opposite between the two indicators), but that usually doesn't make a lot of difference.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Al_Gorithm
Posted : Friday, July 7, 2017 11:10:17 AM

Registered User
Joined: 6/30/2017
Posts: 1,227

Thanks traderlady! I never saw this post before, but it's the same techinque Julia demo'd in a webinar back in the day. That's my default method unless/until I can find something better...

QUOTE (Julia_O)

In general, my approach is to plot Price History as well as a MACD.  Create a Scan Condition for Price Moving Down Smart over a period of 60 bars (I use a Daily chart).  Then create a Scan Condition for MACD Moving Up Smart over a period of 60 bars.   Add both conditions to an EasyScan.  The resulting stocks should be those that exhibit a three month (roughly) positive divergence betweeen Price and MACD.

Thanks, Bruce! The linear regression slope is a good idea. I can always count on you to be (at least) one step ahead of me.

I'm not married to Elder's method, but his definition of a MACD divergence is a little more specific, and probably not "scannable" in TC2000. Even in TradeStation, his programmer has only developed a "semi-automatic" divergence scanner.

A picture can explain it better than I can...

Not all patterns are this perfect, of course, but it's a great teaching example.

At point A, price traces a new low, and MACD Histogram also traces a new low.

At point B, price rallies a bit, and MACD Histogram crosses the zero line and turns positive. (This is the feature that confounds most attempts at scanning.)

At point C, price sinks to a new low, but MACD Histogram declines to a shallower bottom. At this point, prices are lower, but the bottom of MACD Histogram is higher, displaying a divergence and a potential for a reversal.

There's a short video on Vimeo that's a great explainer. It's almost 12 minutes, but after 5 minutes he starts showing multiple examples, so you can fast forward once you've got the concept. I can't say I totally agree with his opinion that the scanner can't be totally automated - I'm fairly confident I can do it with the right programming language ... but not in TC2000. I'm currently just using Julia's technique, and using the space bar to flip through charts, eyeballing for the MACD Histogram crossovers. Better than nothing, but lots of rooms for improvement.

If you want to check out the video, it's here: https://vimeo.com/82506877. Highly recommended if you trade (or are interested in) price/momentum divergences.

Of course, Elder does not have a monopoly (UnclePennybags joke, get it? ;) on the definition of a divergence, and divergences don't always guarantee a reversal, but they can catch some pretty sweet trades.

For bonus points, if the second price high (or low) is a false breakout, it's an even better sign.

 

Bruce_L
Posted : Friday, July 7, 2017 11:34:44 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

Well the general idea of that formula is fairly straightforward (and something I have explored previously), but we are stymied by the offset and period parameters only taking numeric integers as arguments.

The following will not work, but you can hopefully see the basic idea.

Check for a pivot low in the MACD Histogram (low surrounded by two higher lows on each side).

MACD(12, 26, 2) - XAVG(MACD(12, 26, 2), 9) = MIN(MACD(12, 26) - XAVG(MACD(12, 26), 9), 5)

Determine the offset since the last time this was true prior to this most recent pivot low.

TrueInRow(NOT(MACD(12, 26, 5) - XAVG(MACD(12, 26, 5), 9) = MIN(MACD(12, 26, 3) - XAVG(MACD(12, 26, 3), 9), 5)), 50) + 5

Check for price to be lower between these two points with MACD being higher (but below zero) and greater than zero in between these two points.

MACD(12, 26, 2) - XAVG(MACD(12, 26, 2), 9) = MIN(MACD(12, 26) - XAVG(MACD(12, 26), 9), 5) AND C2 < C(TrueInRow(NOT(MACD(12, 26, 5) - XAVG(MACD(12, 26, 5), 9) = MIN(MACD(12, 26, 3) - XAVG(MACD(12, 26, 3), 9), 5)), 50) + 5) AND MACD(12, 26, 2) - XAVG(MACD(12, 26, 2), 9) > MACD(12, 26, TrueInRow(NOT(MACD(12, 26, 5) - XAVG(MACD(12, 26, 5), 9) = MIN(MACD(12, 26, 3) - XAVG(MACD(12, 26, 3), 9), 5)), 50) + 5) - XAVG(MACD(12, 26, TrueInRow(NOT(MACD(12, 26, 5) - XAVG(MACD(12, 26, 5), 9) = MIN(MACD(12, 26, 3) - XAVG(MACD(12, 26, 3), 9), 5)), 50) + 5), 9) AND MACD(12, 26, 2) - XAVG(MACD(12, 26, 2), 9) < 0 AND MACD(12, 26, TrueInRow(NOT(MACD(12, 26, 5) - XAVG(MACD(12, 26, 5), 9) = MIN(MACD(12, 26, 3) - XAVG(MACD(12, 26, 3), 9), 5)), 50) + 5) - XAVG(MACD(12, 26, TrueInRow(NOT(MACD(12, 26, 5) - XAVG(MACD(12, 26, 5), 9) = MIN(MACD(12, 26, 3) - XAVG(MACD(12, 26, 3), 9), 5)), 50) + 5), 9) < 0 AND MAX(MACD(12, 26, 3) - XAVG(MACD(12, 26, 3), 9), TrueInRow(NOT(MACD(12, 26, 5) - XAVG(MACD(12, 26, 5), 9) = MIN(MACD(12, 26, 3) - XAVG(MACD(12, 26, 3), 9), 5)), 50) + 2) > 0

Again, this does not work, but that is the syntax I would use if it did. It doesn't check for the pivot in price to be exactly simultaneous (or even really check for the pivots in price at all), but then, that doesn't happen in the image used as an example.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Al_Gorithm
Posted : Friday, July 7, 2017 12:08:01 PM

Registered User
Joined: 6/30/2017
Posts: 1,227

Cool, Bruce. Thanks! Yeah, the "simultaneous" thing isn't important - you might never find a divergence that way. Off the top of my head, if I had a procedural programming language, I'd probably just track Price and MACD-H highs and lows every time MACD-H crossed its zero line. Then every crossover you can just inspect the last few highs and lows of price and momentum. There's probably a flaw in my logic there somewhere, but it's moot since I can't code it, and I'm not migrating to TradeStation or another platform anytime soon.

Yeah, there's sooooo much about TC2000 that blows away the competition (including your support). I just wish backtesting and a programming language (as opposed to "just" a formula language) was available. But no tool is going to ever have everything everyone wants. You're awsome.

While you were responding I was looking for another example - this time with a false breakout. Actually that brings up the next question: what's the easiest/best way to scan for a false breakout?

In the example below you can see the low of that tall green bar breaking below the most recent swing low, but it couldn't hold that level and closed above the low of that swing low. This should be easier that divergence scanning ... you "only" look at highs, lows, and closes ... the complicating factor might be the lookback period for the most recent swing low (or swing high looking for breakouts to the upside).

Al_Gorithm
Posted : Friday, July 7, 2017 12:22:40 PM

Registered User
Joined: 6/30/2017
Posts: 1,227

I guess what I'm thinking is that if I can add a false breakout component to the Moving Up/Down Smart scan, I would have fewer charts to space bar through. I'd only be looking at charts who just had a false breakout, had some "recent divergence" - then I can eyeball for MACD-H zero line crossovers. Even if there's no crossover, the chart might still be tradeable. Elder's good, but he ain't God :)

There's more than one way to skin a cat ... or a market.

Bruce_L
Posted : Friday, July 7, 2017 12:38:57 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

You have similar issue as the formula above in that the offset parameter needs to be an integer number and can't be a formula. So we can't just write the following because it does not work.

ABS(L(TrueInRow(NOT(MINL2 > L2 AND L2 < MINL2.3), 50) + 2) - (L + C) / 2) < (C - L) / 2

Now because the base formula is fairly short, we can use other methods to determine the low at the most recent swing low. The formula ends up being quite long however (this does work).

ABS(IIF(MINL2 > L2 AND L2 < MINL2.3, L2, IIF(MINL2.1 > L3 AND L3 < MINL2.4, L3, IIF(MINL2.2 > L4 AND L4 < MINL2.5, L4, IIF(MINL2.3 > L5 AND L5 < MINL2.6, L5, IIF(MINL2.4 > L6 AND L6 < MINL2.7, L6, IIF(MINL2.5 > L7 AND L7 < MINL2.8, L7, IIF(MINL2.6 > L8 AND L8 < MINL2.9, L8, IIF(MINL2.7 > L9 AND L9 < MINL2.10, L9, IIF(MINL2.8 > L10 AND L10 < MINL2.11, L10, IIF(MINL2.9 > L11 AND L11 < MINL2.12, L11, IIF(MINL2.10 > L12 AND L12 < MINL2.13, L12, IIF(MINL2.11 > L13 AND L13 < MINL2.14, L13, IIF(MINL2.12 > L14 AND L14 < MINL2.15, L14, IIF(MINL2.13 > L15 AND L15 < MINL2.16, L15, IIF(MINL2.14 > L16 AND L16 < MINL2.17, L16, IIF(MINL2.15 > L17 AND L17 < MINL2.18, L17, IIF(MINL2.16 > L18 AND L18 < MINL2.19, L18, IIF(MINL2.17 > L19 AND L19 < MINL2.20, L19, IIF(MINL2.18 > L20 AND L20 < MINL2.21, L20, IIF(MINL2.19 > L21 AND L21 < MINL2.22, L21, IIF(MINL2.20 > L22 AND L22 < MINL2.23, L22, IIF(MINL2.21 > L23 AND L23 < MINL2.24, L23, IIF(MINL2.22 > L24 AND L24 < MINL2.25, L24, IIF(MINL2.23 > L25 AND L25 < MINL2.26, L25, IIF(MINL2.24 > L26 AND L26 < MINL2.27, L26, IIF(MINL2.25 > L27 AND L27 < MINL2.28, L27, IIF(MINL2.26 > L28 AND L28 < MINL2.29, L28, IIF(MINL2.27 > L29 AND L29 < MINL2.30, L29, IIF(MINL2.28 > L30 AND L30 < MINL2.31, L30, IIF(MINL2.29 > L31 AND L31 < MINL2.32, L31, IIF(MINL2.30 > L32 AND L32 < MINL2.33, L32, IIF(MINL2.31 > L33 AND L33 < MINL2.34, L33, IIF(MINL2.32 > L34 AND L34 < MINL2.35, L34, IIF(MINL2.33 > L35 AND L35 < MINL2.36, L35, IIF(MINL2.34 > L36 AND L36 < MINL2.37, L36, IIF(MINL2.35 > L37 AND L37 < MINL2.38, L37, IIF(MINL2.36 > L38 AND L38 < MINL2.39, L38, IIF(MINL2.37 > L39 AND L39 < MINL2.40, L39, IIF(MINL2.38 > L40 AND L40 < MINL2.41, L40, IIF(MINL2.39 > L41 AND L41 < MINL2.42, L41, IIF(MINL2.40 > L42 AND L42 < MINL2.43, L42, IIF(MINL2.41 > L43 AND L43 < MINL2.44, L43, IIF(MINL2.42 > L44 AND L44 < MINL2.45, L44, IIF(MINL2.43 > L45 AND L45 < MINL2.46, L45, IIF(MINL2.44 > L46 AND L46 < MINL2.47, L46, IIF(MINL2.45 > L47 AND L47 < MINL2.48, L47, IIF(MINL2.46 > L48 AND L48 < MINL2.49, L48, IIF(MINL2.47 > L49 AND L49 < MINL2.50, L49, IIF(MINL2.48 > L50 AND L50 < MINL2.51, L50, IIF(MINL2.49 > L51 AND L51 < MINL2.52, L51, 0 / 1)))))))))))))))))))))))))))))))))))))))))))))))))) - (L + C) / 2) < (C - L) / 2



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Al_Gorithm
Posted : Friday, July 7, 2017 12:53:39 PM

Registered User
Joined: 6/30/2017
Posts: 1,227

Thanks! I guess I better get used to flipping through charts with the ol' space bar. Sometimes I wish I wasn't a programmer - maybe I wouldn't have this fantasy about being to automate everything :)

One thing Elder does that helps is setting up an alert when one of his stocks hits a new swing high or low. He gets an alert notification down the road when/if that high or low is breached, and he can keep a closer eye on it to eyeball if there's a potential false breakout - with or without a divergence - brewing.

I don't agree with everything he says, but he does believe that engineers and other techincal folks have a disadvantage or handicap when it comes to trading because they think they can impose order over chaos.

I'm coming around to his way of thinking ... I just hate flipping a gazillion charts if I can tell the computer what to scan for ... on the other hand, actually looking at charts is probably good practice to be a successful trader. :)

Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.