#### Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

# MA cross within 'x' number of past days.

edited March 2015 in Scanning
I know of a scan program offered by another company that permits one to insert a condition to the effect of "and ema(7) of the close crossed above ema(21) of close within last 'x' days". Is there a way to accomplish the same in a Stockcharts scan with the same or better brevity? Actually on the other scanner it can be entered with even less verbage: "and ema(7,close) crossed above ema(21,close) withing last 'x' days."

Thanks

So you are looking for the EMA-7 to be above the EMA-21 today, but somewhere in say the last 5 days it has been below the EMA-21.

As you are looking at EMA's we could use the MACD which defines the difference between two EMA's. A positive MACD Line means EMA-7 is above EMA-21, a negative number means its below.

Thus you want greater than 0 today and less than 0 sometime in the last 5 days. The following scan will do that with just two lines of code.

[type = Stock]
and [MACD Line(7,21,9) > 0.0]
and [Min (5, MACD Line(7,21,9)) < 0.0]