Scanning for "Near Crosses"

Scanning for "Near Crosses"

Crossover scans are often used to find stocks that are undergoing some kind of change, but sometimes nearly crossing over a benchmark is as good as actually crossing it. For example, it is useful to know that a stock's price came very close to its 20-day moving average, even if it didn't quite cross above that average. There are a number of ways to scan for these “near crosses,” as we'll discuss below.

Learn More: Writing Crossover Scans

Using the Plus and Minus Operators

The simplest way to search for a near cross is to use the “+” or “-” arithmetic operators. Let's say we want to look for stocks that are within 50 cents of their 20-day simple moving average. This can be done with a simple scan clause that compares the closing value to the 20-day moving average minus 50 cents:

[type = stock]
and [close >= SMA(20,close)-0.50]

This will find stocks that are no more than 50 cents below their 20-day moving average. However, it will also find stocks that are $10 above their moving average. Usually, you're going to be interested in stocks that are near their moving average (in the neighborhood of having a crossover), so you'll want to put in a clause that sets an upper limit for the close as well:

[type = stock]
and [close >= SMA(20,close)-0.50]
and [close <= SMA(20,close)+0.50]

Now the scan will find stocks that close up to 50 cents above or 50 cents below their moving average. For example, if the moving average of a stock is $15.00 and the closing price is anywhere between $14.50 and $15.50, it will be found by this scan.

Using the Multiplication Operator

One major limitation of using the “+” and “-” operators is that they use a flat amount to calculate the range. 50 cents is a huge amount when you're looking at a $5 stock, but barely even registers when you're looking at a $500 stock.

For this reason, many scanners prefer to use percentages when scanning for near crosses. Let's say we're interested in scanning for stocks that are 4% above or below their 20-day moving average:

[type = stock]
and [close >= SMA(20,close)*0.96]
and [close <= SMA(20,close)*1.04]

The scan is very similar, but, instead of subtracting or adding 50 cents, we will subtract or add 4% from the moving average. 100%-4% is 96%, so we will multiply the moving average by 0.96 (96%) to get the lower limit. Similarly, we will multiply by 1.04 (104%) to set the upper limit at 4% above the moving average.

The advantage of using percentages is that it takes the stock price variable out of the equation. On a $5 stock, 4% is 20 cents, while on a $500 stock, it is $20. So when you use this percentage technique, the definition of “near” scales right along with the price. This is very useful if you are interested in both high- and low-priced stocks in the same scan.

Using the PctDiff() Function

Just like the multiplication operator, the PctDiff() function can be used to scan for near crosses based on percentage.

[type = stock]
and [PctDiff(close,SMA(20,close)) >= -4]
and [PctDiff(close,SMA(20,close)) <= 4]

In the scan above, the lower limit is set by specifying that the difference between the close and the moving average is 4% below (“-4”) the moving average. The upper limit is set by specifying that the difference is 4% above (“4”) the moving average.

The PctDiff() function does the exact same calculations as the multiplication operator. Use whichever syntax you are more comfortable with.

Other Uses for Near Crosses

When we talk about near crosses, most people think of examples like the ones above, where the close is nearly crossing above its moving average, but this syntax can be used to scan for near crosses of volume, indicator values and more. You can use these techniques to scan for anything being near to anything else.

One of the most common alternate uses is to find stocks near a previous high or low. In these examples, you're essentially searching for stocks that “nearly crossed” their historical high or low value.

Stocks within 5% of their yearly high

[type = stock]
and [today's high > yesterday's max(252,high) * 0.95]

Note: Often, the upper limit clause is left out when scanning for stocks near a high. As a result, this scan would also find stocks that are far above their yearly high.

Stocks within 2% of their yearly low

[type = stock]
and [today's low < yesterday's min(252,low) * 1.02]
and [today's low > yesterday's min(252,low) * 0.98]

Note: This example includes both the upper and lower limit. Some scanners might leave out the lower limit clause on a scan looking for lows.

Close within 3% of the daily high

[type = stock]
and [close > high * 0.97]

Note: This last example is a little different in that you are looking for stocks that closed near the top of the day's range (that “nearly crossed” the day's high). Obviously, the close would not be higher than the high for that day, so there is no need to add an upper limit clause here.


There are several scanning techniques available when scanning for near crosses. These are often used to scan for stocks whose prices are near their highs, lows or moving average.

When scanning for “nearness,” we strongly recommend that you use percentages rather than a fixed amount. This takes price out of the equation and allows your scan to find both high- and low-priced stocks that meet your criteria.