New Members: Be sure to confirm your email address by clicking on the link that was sent to your email inbox. You will not be able to post messages until you click that link.

MACD divergence

Hi, I am trying to write a scan for MACD divergence with double bottom within recent at least 20 bars, please take a look at the daily chart of BABA as of 12/31/2016. Can someone please help ? thank you.

Comments

  • markdmarkd ✭✭✭
    edited January 17
    Probably the easiest way to find potential divergence situations is to test for a price MA falling and a MACD signal line rising.

    So you might choose a falling MA 21. To test for a falling MA, compare its value some number of bars ago to its current value. The current value should be less, so:

    and [sma(21,close) < 10 days ago sma(21, close)]

    You can try a value other than 21 for the MA and a value other than 10 for a look back value to see what works.

    To test for a rising MACD Signal, you would do the same test, but the current value should be greater than the look back value, so:

    and [MACD Signal (12,26,9) > 10 days ago MACD Signal (12,26,9)]

    Getting the double bottom is tricky, because the distance between them varies so much. You could try testing for a Price Channel break. First, you have to test that the channel has been flat for some period of time. Its hard to know how long this flat period should be so you might try testing for a flat period in the middle, rather than end to end - so maybe:

    and [ 10 days ago Lower Price Chan(21) = 15 days ago Lower Price Chan(21)]

    And then test for a new low over some period of time

    and [low = min(21, low)]

    You might try min(10, low), instead, or some other number that makes sense to you.

    If you run this scan as of 12/22, it picks up BABA.

    You might want to try leaving off the last two lines ( or include them in the scan but put "//" in from of each line to prevent them from executing) because not every MACD divergence is going to be followed by a double bottom, but could still be a good trade. Either way, run the scan every day and make a watch list of the most promising results. Note that getting a hit does not guarantee a good trade (compare VIPS to BABA - same sector and industry, hit on the same scan, but different results - VIPS is under its falling long term MA, BABA is above its rising long term MA). You should back test the scan for random dates in the past (both versions) to get a feel for what makes a good hit or a bad hit.

  • Thank you for your help, MarkD. How do I write a simple scan where I want to see MACD(12,26,9) had been below 0 for say last 5 days (even still below zero line) as well as RSI(7) had been less than 50 for last 5 days,but today RSI(7) jumped to above 50 line ? thanks.
  • markdmarkd ✭✭✭
    So you want the maximum MACD (Line or Signal?) for the last 5 bars to be less than zero - select "Max" from the Technical Indicator drop down and edit it for your condition. Same thing for RSI except you have to put "1 day ago" in front of the max condition (because today it's above 50).

    For RSI crossing above 50, you need the "cross above" operator, which is "x", so

    and [RSI(7) x 50]
  • Thanks for the reply, but I still don't get this MIN & MAX things. There is no drop down for these parameters, except indicators, so don't know where to place them. I am looking for simple thing; MACD(12,26,9) had been below 0 for past 5 bars, and so is RSI(7), except RSI(7) crossed above 50 today. Please write it so I can get it, then I can change the days whatever I want, 5 or 10. thank u.
  • markdmarkd ✭✭✭
    Here's where to find max and min.



    Select max first. Edit it so 5 and MACD Signal(12,26,9) (or Line) are inside the parentheses. Then outside the parentheses put " < 0". All of that should be inside the brackets "[ ]".

    Then select min. Edit it so 5 and RSI(7) are inside the parentheses. Then outside the parentheses add "<50". AND, in front of "min" put "1 day ago".

    Then and the RSI x 50 line from the last answer.
  • Thank you for your reply, however, I am still getting syntax errors;

    [type = stock] AND [country = US] AND [Daily SMA(20,Daily Volume) > 40000]
    and [optionable is true]
    and [SMA(50) > SMA(200)]
    and [Max 5 (MACD(12,26,9)) <0]

    what is wrong with the above scan ?
  • markdmarkd ✭✭✭
    [type = stock] AND [country = US] AND [Daily SMA(20,Daily Volume) > 40000]
    and [optionable is true]
    and [SMA(50) > SMA(200)]
    and [Max(5, MACD Line(12,26,9)) <0]

    The leading parenthesis for max( ) was misplaced.

    For MACD you have to specify Line, Signal or Hist.

    For clarity, it would be better to write sma(50, close) > sma(200, close).
  • Thank You, MarkD. Now I am getting it, and it works. :)
Sign In or Register to comment.