#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Scan for Stocks that have been under their 50MA and 200 MA and now closed above both (weekly chart )

How can a scan like this be created. thanks

• mod
edited January 24
The first things to think about are:

Do you really mean 50 week MA - that would be 250 daily bars, or almost a year - and 200 week MA - that would be a thousand daily bars, or about four years. If you do, that's fine.

Or do you mean the 50 MA daily expressed as weeks - that would be 50 days divided by 5, or 10 weeks. And 200 MA daily would be 200 days divided by 5, or 40 weeks.

Then you have to decide how many weeks ago were prices under both MAs. Different choices will give you different results, although some may overlap.

Let's say you choose 10 weeks ago. You might have to change this number depending on how you like the results.

So, first, check that the close is above both MAs. I'll do the first one, you finish the second one:

// close is above (>) both MAs
and [weekly close > weekly sma(10, weekly close)]
and [........]

Notice that when you want to use the weekly time frame, you have to put "weekly" in front of everything (except numbers), even things inside parentheses like sma( ).

Then check for the close below (<) both MAs 10 weeks ago.

// prices were below both MAs 10 weeks ago
and [10 weeks ago weekly close < 10 weeks ago weekly sma(10, weekly close)]
and [...........]

I'll let you fill in the last line.

Notice you DON'T put the "10 weeks ago" inside the sma( ) as you did with "weekly".

Another approach might be to test just for the 50 MA to cross above the 200 MA. The 50 can't cross above the 200 unless prices have been rising.

That would be

and [weekly sma(10, weekly close) x weekly sma(40, weekly close)]

The "x" symbol is the "cross above" operator. It means that, on the previous bar the 10 was below the 40, and on the current bar the 10 is above the 40.

• thanks for the info. Look at ESIO 4 year weekly chart ,see the 4 tests of the 200MA and the clean break upward around may 2017.this is a setup I am trying to scan for. https://stockcharts.com/h-sc/ui?s=ESIO&p=W&yr=4&mn=0&dy=0&id=p78888394806&a=573021391&listNum=350
• mod
edited January 24
Then you could test for a falling 200 MA , and the 50 MA below it (direction doesn't matter), and a close crossing above it.

The test for a falling MA is the current MA value is less than the MA value some number of weeks in the past.

That doesn't guarantee that the chart will develop like ESIO. For research purposes, you would set the run date for the scan some time in the past (use Friday dates for weekly scans).