#### Howdy, Stranger!

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

# Crossing

Hi...newbie here. I've searched but not found anything that was helpful for me in my newness. Two questions:

1 -- Would the following be correct for when price crosses above certain levels in the monthly FORCE and Wm's %R indicators? --

and [monthly FORCE(13) crosses > 0.0]
and [monthly Williams %R(14) crosses > -80.0]

2 -- How would I word it when these two indicators cross their MA?

• mod
edited May 2016
Hi @vregan ,

This is the corrected version:

and [monthly FORCE(13) crosses 0.0]
and [monthly Williams %R(14) crosses -80.0]

In both cases, the ">" sign is unnecessary. If you want, in place of the word "crosses" you could use the "cross above" operator, which is "x".

and [monthly FORCE(13) x 0.0]

The scan engine's operators are listed here, about 1/3 of the way down the page:

For crossing an MA, you would have to decide whether you want an exponential moving average (ema) or simple moving average (sma), and then the length of the average.

Let's assume an sma of 12 bars. The general form the sma (and ema) function is

sma(period, value)

So in the first case, the period is 12 and the value is monthly Force(13), so:

and [monthly Force(13) x monthly sma(12, monthly Force(13))]

Note you have to modify each term (Force and sma) with the time frame, in this case "monthly"

For Williams %R(14), just substitute that indicator for Force in the statement above. Watch your parentheses and your brackets.

Also note: if you want one value to cross BELOW another, instead of cross above, you would still use the "cross above" operator "x", but you would switch the order of the values - so, for instance, if you want to look for the indicator crossing below its MA, you would actually write the scan to look for the MA crossing above the indicator. So it would look like this:

and [monthly sma(12, monthly Force(13)) x monthly Force(13)]
• Thank you very much for all of the help. I'm concerned though because I've used the following (using many indexes to increase the odds of a hit), going back 1,000 days and gotten "'0' count":

[favorites list is 42] // 'ETF's Good Volume (w/Inv & Lev)'

and [monthly FORCE(13) crosses 0.0]
and [monthly Williams %R(14) crosses -80.0]

and [group is ETF]
and [group is SP500]
and [group is NASDAQ100]
and [group is SP400]
and [group is SP600]
• mod
edited May 2016
I think maybe you are confusing indexes with groups.

For the scan engine, an index is an individual symbol that begins with "\$", like \$SPX, \$MID, etc.

A group is a set of symbols in the database that have a common classification, like membership in the SP500 index. Many or most of these classifications, I believe, are exclusive - that is, a stock in the SP500 is not in the SP400, and, as far as I know, no ETF is also in an SP or NASDAQ index.

When the scan engine looks at a symbol, ALL conditions in the scan must be true to get a hit. So let's say it gets to an ETF group symbol - that's true, so it checks the SP500 group - the symbol is not there - so that symbol is not a hit and it's on to the next one, where the same thing will happen - it will find at least one false statement.

If you want to check all these groups and your favorites list, you need an "or" statement.

In an "or" statement, only ONE of the alternative conditions needs to be true for the scan engine to evaluate it as true and go on to the next statement.

So, you would edit you scan like this (note: lines that begin "//" are comments; the scan engine doesn't see them):

//begin Williams scan

// choose stocks to look at

[ // this bracket begins "or" statement

[favorites list is 42] // 'ETF's Good Volume (w/Inv & Lev)'
or
[group is ETF]
or
[group is SP500]
or
[group is NASDAQ100]
or
[group is SP400]
or
[group is SP600]

] // end "or" statement

// conditions to look for

and [monthly FORCE(13) crosses 0.0]
and [monthly Williams %R(14) crosses -80.0]

// end Williams scan

Note the two brackets around ALL the "or" conditions. Those are necessary so that the scan engine will know to treat all these conditions as one individual statement - so only one conditions has to be true for the whole statement to be true.

Also, note that if you include the [group is ETF] statement, the scan engine will look at ALL ETFs, not just the ones you specified in the favorites list. The results list will not tell you where it got the symbol - the group or your list.
• Wow, you are amazing!! Thank you for the additional help.

One more question: When I set the number of days on a scan it says "Starting _X_ trading days before..." Is this the total number of days that will be scanned, or will the scan look at just that day?

I ask because when I set the number the results vary between 50 days and 5 days. I thought that if it was looking at all of the days (50) the results that come up when 5 is the setting would be included in the 50 setting results, but there are two different sets of symbols. E.g.: 50 days shows BWX and GDX, and 5 shows ERX.

(BTW, I used slightly different parameters than what we've been discussing -- added a line for CCI).
• mod
edited May 2016
I guess the word "Starting" is a little misleading. Maybe it should say something like "Run my scan as of..."

The scan engine looks only at data preceding and including the offset date you choose. So if you were to choose, say, April 5, the scan engine would NOT look at data for April 6 forward.
• What is the length of the lookback period?
• mod
Whatever is necessary to calculate the values of any indicators or overlays or other values requested in your scan. For instance, if you have a condition "and [close x sma(200, close), it looks back 200 bars to get the sma(200, close) value.

I'm not sure when the database begins. It has been extended several times and it is at least several years for daily data.
• mod
Here's what a support page says about the scan engine data:

Q: What time of day does the Scan Engine start updating?
A: The first update for the scan engine usually begins at 9:31 AM Eastern Time. Throughout the rest of the trading day, the ScanEngine is updated every 1-2 minutes.

Q: How much data is in your Scan Engine?
A: Our Scan Engine contains 2500 daily data points (roughly 10 years) for each of the 50,000+ different stocks, indices, and mutual funds that we track. Scans that require longer duration indicators will lose accuracy.

Q: What data periods are supported by the Scan Engine?
A: The Scan Engine allows users to create scans based on Daily, Weekly and Monthly bars. It does not support scans based on intraday (1-minute, 5-minute, etc.) bars.
• When trying the wording for sma crosses with an indicator, I get a very large list of indexes, stocks and some ETFs, when all I'm looking for is ETFs:

[group is ETF]

and [monthly Force(13) x monthly sma(12, monthly Force(13))]
or [monthly CCI(30) x monthly sma(12, monthly CCI(30))]

What can I do to just get ETFs using multiple 'or' lines?
• mod
It's the "or" issue again.

When you use "or" by itself, you get everything you ask for. So you get everything that is and etf, and everything that meets your force condition and everything that meets your cci condition - with just plain "or" you are saying that a symbol only has to meet ONE condition in your entire scan to be a hit - give me ANY symbol that meets at least one condition.

If you want symbols that meet EVERY condition, you would use ONLY "and", with no "or" statements at all.

If you want symbols that meet SOME conditions, then you have to separate out the conditions that MUST be met from the optional conditions.

In your scan, "group is ETF" is a condition that MUST be met, so you need to keep it away from the "or" operator. The Force condition and the CCI condition are optional (you want one or the other - both is fine, but at a minimum one or the other), so you want to group those together.

Brackets group the optional conditions and keep the must have conditions separate.

So,

[ group is ETF ]

and

[ // <----- you must have this bracket at the beginning of your optional conditions

[monthly Force(13) x monthly sma(12, monthly Force(13))]
or [monthly CCI(30) x monthly sma(12, monthly CCI(30))]

] // <----- you must have this bracket at the end of your optional conditions

• Thank you for your continuing, excellent help!