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.

EMA 20 above EMA 50 for x number of days

Part of one of my scan is trying to find stocks which the EMA 20 is being above EMA 50 for x number of days, and rising. Once found, then I will look for an even shorter EMA (3, 5, 10) that crosses above EMA 20. This "ideally" should find strong stocks that made a pull-back, and continue their ascent. But I want to make sure the EMA 20 never went below EMA 50.

E.g. this scan

and [today's ema(20,close) > 20 days ago ema(50,close)]

will list stocks that might include EMA 20 that was below "yesterday's" EMA 50, though it will be above 20 days ago.

How to make sure that during x number of days the EMA 20 did not go below EMA 50?




Comments

  • MACD Line represents the difference between the short ema (default 12) and the long ema (default 26).

    As long as the short ema is above the long, MACD Line is above 0.

    So, in your case, substitute 20 and 50 for 12 and 26, and then test that the minimum value of MACD Line for x days is greater than 0.

    So, if the test period is, say, 20 days:

    and [min(20, MACD Line(20, 50, 9)) > 0]

    Watch the parentheses - one pair for min() and one pair for MACD Line().

    Note: you can test this method with the annotation app. Set up a chart with MACD(20, 50, 9) and ema 20 and ema 50 on the chart. Use the vertical line tool to line up the ema crossovers with MACD Line dropping below zero.
Sign In or Register to comment.