#### Howdy, Stranger!

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

# Scan for ema(1,h,50)

Merry Christmas dear stockcharters!

Refering to stockcharts' guide: When we want to shift an eMA 50 days in the future we can use ema(1,50).
For the highs we use ema(1,h,50).

Now my question:

How can we scan for a crossing of the ema(20) with ema(1,h,50) in the last week? I'm wondering especially about the expression of the ema(1,h,50).

Any useful ideas?

Best regards,
stokkcharts

• mod
I'm not sure this is useful, but it seems you could just write the scan for a crossover today, ema(20) x ema(1,h,50) and then run it for each day in the prior week, or, ask for 5 days ago ema(20) < 5 days ago ema(1,h,50) and ema(20) > ema(1,h,50). I haven't actually tried this, just speculating.
• Problem is the scan engine doesn't recognize ema(1,high, 20)...
• mod
edited December 2015
Sorry - still working off Christmas dinner.

I think you can do this:

and [sma(20,close) x 50 days ago high]

The ema with a "1" parameter is the same as the value itself for that period. So if you move the ema ahead 50 days, it should still equal the value 50 days back from the advanced ema. So when the ema(20) crosses the value 50 days ago, it should also cross the advanced ema.

If you try the above code with [group is sp500] you will get a few hits (as of 12/24 close).

Then set up a style with the advanced ema and the ema 20 and you should see that they cross on the last bar.

I think the most accurate way to do this for the past week is to run it for each individual day. It would take some work to figure out how deal with the possible sequences of highs and the corresponding possible values of the ema. I'm not sure you could do it so that it would hit every actual crossover instance.
• Thank you markd,

this is the solution: [sma(20,close) x 50 days ago high] .
There always seems to be a workaround I first could not see.

I hope the question inspires new ideas for other users.

Best regards!

PS: Maybe stockcharts should make a test for interested users to test their scan abilities, because most of us are new to programming...

• mod
edited December 2015
Hi @stokkcharts , glad that worked for you.

Regarding scan writing, it might help to pick up a very basic book on programming, maybe from amazon - go to books and enter "programming" in the search window and read the reviews of any book that has the word "beginning" in the title. Pick a very simple language - in the old days, it was BASIC. If that is still around I would recommend it, but maybe there is something else today. But not SQL - you need something in what's called the "procedural language" area. SQL is a query language, which is different. Also, you probably don't want HTML or other internet languages. I would also hesitate to go with C, C++, C#, or Java because you need to learn some memory management concepts that BASIC avoids and that have no relevance to scanning.

Learning to program is really learning to look at problems in a particular way. Machines cannot make assumptions the way people can, so you have to "explain" the problem to it in a level of detail that you unconsciously skip over when explaining things to another person. It's a little like having to rephrase things in different ways for someone who doesn't speak your native language very well. With a little practice, you begin to see that there are many ways to look at a problem, and often many things which you didn't realize you were actually overlooking. Getting into that habit makes it easier to hit on a workable solution.

If you have the time and some spare cash, you might be able to find an adult ed or community college class to help you make progress. Or there may be on-line tutorials. Some of the books may even come with CDs (or probably DVDs these days).

There are probably a lot of people on this forum who have more up to date experience who would be willing to share recommendations for books or other resources to get you going.

One more thing - unlike some teachers you may have had - the computer doesn't show the least bit of disapproval when you get something wrong. It just waits patiently until you get it right - and you can try as many times as you want. It's actually a great way to learn.

P.S. Here's a link to a promising book - I haven't actually read it or used it, but from the available preview, it looks like the right approach: