- 2.4K All Categories
- 2K StockCharts
- 350 SharpCharts
- 107 Other Charting Tools
- 43 Saved Charts and ChartLists
- 1.3K Scanning
- 60 Data Issues
- 146 Other StockCharts Questions
- 172 Technical Analysis
- 126 Using Technical Analysis
- 1 InterMarket and International
- 17 Market and Breadth Indicators
- 28 Market Analysis
- 88 Trading
- 88 Trading Strategies
- 154 S.C.A.N the StockCharts Answer Network forum
- 59 Using this StockCharts Answer Network forum
- 95 s.c.a.n. archives
- 13 Off-Topic
- 9 The Cogitation & Rumination Emporium
- 4 Forum Test Area

New Members: Be sure to confirm your email address by clicking on the link that was sent to your email inbox. You will not be able to post messages until you click that link.

When I ran what I have below, one of the charts (HRB) showed the last two days below any previous low for more than a year. That certainly obeys the last clause, but shouldn't the first clause keep it from including anything lower than 1% above the 52-week low? My thinking for these two clauses is that the first would keep today's close in that range near the low for the last year, and the second would keep it above the low, perhaps back up on top the low of the consolidation below the yearly low.

[[today's low < yesterday's min(260,low) * 1.02] and [today's low > yesterday's min(260,low) * 1.01]]

and [today's close > yesterday's min(5,low)

## Comments

If you change the default and set the scan start date to "Last market close (Mar 4)" (look in the drop down), the scan engine ignores data generated during the day today, so HRB's low from (calendar) yesterday is "today's" low, so HRB doesn't appear in the results.

I remember tripping over this, too, a few years back. Maddening. I haven't checked the documentation to see if this wrinkle is mentioned now.

I ran the scan after the market closed, and also set the start date to Last market close (Mar. 7) in the drop down to make sure. I still catch HRB (only one low below today's close) in it, as well as a few others that don't conform. I'm attaching a screenshot with one that conformed (lows below today's close marked with a star), one that only four of the five that did (odd man out circled), and the HRB that has only one low below today's close. Shouldn't the first clause be excluding it completely since there's only two candles in that island that gapped so far below the low just two days ago?

I do see other things that I need to do in the scan to get what I'm looking for, but if that last line doesn't work, the rest of my idea isn't going to either.

But, this condition

and [today's close > yesterday's min(5, low)]

requires only ONE low below today's close. It does not say you can't have lows above today's close. It just says, you want the lowest low, whichever one that is, to be lower than today's close.

But, if I understand you correctly, you really want ALL the lows lower than today's close. In other words, the highest low is lower than today's close - so:

and [today's close > yesterday's

max(5,low)]That says, no low in the last 5 bars (starting yesterday) was greater than today's close.

Your syntax as posted above is fine - except you have an extra pair of brackets in the first line - you don't need to group those statements, although, in this case, there is no harm if you do.

I want to just limit the scan to the lower x% of the 52-week range. This line doesn't pass the syntax test:

and [today's close < (yesterday's high(253,low*0.1)]

It looks like it doesn't like a space ("") in it, but I don't see what is the problem. My intention is for it to limit the scan to the lowest 10% of the range.

The other question is about the difference between the two arguments [today's close > yesterday's min(5, low)] and [today's close > yesterday's max(5,low)]. I don't understand why min would make it require only one of the previous 5 days' low to be lower than today's, but max would require all 5 days' lows to be lower. How is the scanner interpreting those terms? Thanks.

Suppose the last five lows are:

21 23 20 19 22

The minimum value is 19.

The maximum value is 23.

So:

If today's close is 20, close > min(5, low) is true, because 20 > 19

If today's close is 20, close > max(5, low) is false, because 20 < 23

If today's close is 24, both statements are true because 24 > 19, and 24 > 23.

If today's close is 18, both statements are false because 18 < 19 and 18 < 24.

Now your scan condition:

Here's your line:

and [today's close < (yesterday's high(253,low*0.1)]

There is no function called "high( )" (good guess, though), so the scan engine would reject that. Unfortunately, you can't pick functions from the the drop downs, so you just have to know them. Here's a link to the support page that explains them (although it could explain a them little more with an actual example):

https://stockcharts.com/docs/doku.php?id=scans:functions

So you are looking for a close in the lowest 10 per cent of the 52 week range. This is a little complicated because to get the 52 week range you have to write something that picks out the highest high and the lowest low in the last 52 weeks - or, in the daily time frame, 253 days as you have defined it.

So, the highest high in the last 253 days is "max(253, high)".

The lowest low in the last 253 days is "min(253, low)".

Now we need the range, which is the difference between the max high and the max low, so we have to subtract the low from the high. It's best to put arithmetic operation like that in brackets, so:

[ max(253, high) - min(253, low) ]

So that's the 52 week range. If the high were 50 and low were 30, that phrase would produce the number 20.

Now we want 10 per cent of the range. So, we would multiply the range by .1, as you had in your scan - use another set of brackets for that operation:

[ [max(253, high) - min(253, low)] * 0.1 ]

Using the example high and low, 50 and 30, that will resolve to the number 2, as 10 per cent of 20 is 2.

Now comes the tricky part - you want the close to be less than 10 per cent above the 52 week low.

So how do we write 10 per cent above the 52 week low?

We know how to write the 52 week low because we did it above:

min(253, low)

And we know how to write 10 per cent of the 52 week range because we did it above:

[ [max(253, high) - min(253, low)] * 0.1 ]

So, putting those two things, together, 10 per cent above the 52 week low is:

[min(253, low) + [ [max(253, high) - min(253, low)] * 0.1 ] ]

Now we want today's close to be less than that number, so the final scan line will be:

// close less than 52 week low plus 10 per cent of 52 week range

and [today's close < [min(253, low) + [ [max(253, high) - min(253, low)] * 0.1 ] ] ]

Let me know if that all makes sense. Watch your brackets.

for min: "today's close is greater (higher) than the lowest low (minimum) of the last 5 candles' lows," and

for max: "today's close is greater (higher) than the highest low (maximum) of the last 5 candles' lows"?

I still have a few more refinements to try to add, but this has gotten me so much close to my goal, and has been very helpful toward understanding how to compose the statements. Thanks so much!

" Unfortunately, you can't pick functions from the the drop downs, so you just have to know them. "

That is incorrect. You can find max, min, absval, PctDiff, PctChange, sma, ema and kama under the "Technical Indicators" drop down. They make up the first grouping at the top of the drop down list.

SMA, EMA and KAMA are explained in Chart School.

This support link explains the others:

https://stockcharts.com/docs/doku.php?id=scans:functions