- 2.6K All Categories
- 2.1K StockCharts
- 371 SharpCharts
- 115 Other Charting Tools
- 53 Saved Charts and ChartLists
- 1.4K Scanning
- 65 Data Issues
- 152 Other StockCharts Questions
- 194 Technical Analysis
- 142 Using Technical Analysis
- 1 InterMarket and International
- 19 Market and Breadth Indicators
- 32 Market Analysis
- 95 Trading
- 95 Trading Strategies
- 158 S.C.A.N the StockCharts Answer Network forum
- 63 Using this StockCharts Answer Network forum
- 95 s.c.a.n. archives
- 14 Off-Topic
- 10 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.

## Comments

I'm guessing you want the today's close to be above yesterday's low, but only by some small fraction of yesterday's range. Or, to put it another way, today's close is in the lower portion of yesterday's range.

That would look like this:

and [close > 1 day ago low]

and [close < 1 day ago low +[ [1 day ago high - 1 day ago low] / 3 ] ]

There are two statements because you need to specify the top AND bottom of the area where you want the close to be (assuming I'm right about what you want).

You could also multiply by a decimal fraction, and use the keyword "range" to simplify things:

and [close > 1 day ago low]

and [close < 1 day ago low + [ 1 day ago range * .33] ]

So, if 4 and 3 are yesterday's high and low of a symbol in the database, the scan engine would plug in those numbers like this:

close > 3 and close < 3+ (1 * .33), or

close > 3 and close < 3.33

And if today's close for that symbol is 3.25 , you would want that symbol on the results list because 3.25 fits both conditions (i.e., greater than 3 and less than 3.33)

note:

You will get a warning message because you are comparing values from different dates (meaning different offsets - today and 1 day ago) but it will run correctly.

One statement is: the price must be greater than some value - that value is the lower bound of the range.

The other statement is: the price must less than some value - the upper bound of the range.

So if you want the price to be in the lower half of today's range:

and [close > low] // the lower bound, today's low

and [close > low + [range * .5] ] // the upper bound, the midpoint, or half of today's range added to today's low

If you want price to be in the upper half:

and [close > high - [range * .5] ] // the lower bound, the midpoint, or half today's range subtracted from today's high.

and [close < high] // the upper bound, today's high

note: the order of the two statements doesn't matter. You can specify the upper bound first or the lower bound first. But, to keep things straight in your mind, it's a good idea to always choose one bound first - always lower or always upper. It's also a good idea to add a comment like // lower bound and // upper bound so you remember what you were doing when you come back to your scan later. All professional coders comment their code.

p.s.

if you want to calculate range yourself (there is nor reason to do that, it just makes things more complicated with brackets and signs, but if you do), range is ALWAYS the

DIFFERENCEbetween high and low : [high-low].range is NEVER the SUM of high and low [high+low]. The sum of high and low will always be a number, but the number doesn't represent anything. In other words, it doesn't capture any useful relationship between prices.

[Close > Low+[[High-Low]]/2]

probably should be

[Close > Low+[ [High-Low]/2] ] // move the second bracket from after "low]" to after "/2";

This says, add to the low half today's range.

and then

[Close < High-[[High-Low]]/2]

probably should be

[Close < High-[[High-Low]/2] ] // same thing

You could probably get away without the second set of brackets altogether, and just say

[close < high-[high-low]/2]

where the /2 divides only the " [high-low] " and not "high-[high-low]" .

But, I think its better form to use the brackets around it -

high - [ [high-low]/2 ]

That way, when you are debugging your scan, there's no doubt the /2 applies to only the [high-low]. But that's a style choice.

***

[high + low] / 2 gives you the midpoint of the range - in other words, the simple average of high and the low.

So, if you wanted the today's close in the bottom half of the range, you could say

and [close > low] // today's low is the lower bound

and [close < [high+low]/2] // today's midpoint is the upper bound.

The reason to use

low + [range * .5]

is that its easier to change the upper bound

low + [range * .3] // upper bound is lower 3 tenths of range

low + [range * .25] // upper bound is lower quarter of range

low + [range * .75] // upper bound is the lower three quarters of the range

etc.

Easier to change the decimal than figure out the right divisor for [high+low].

For the first part, choose one of these:

today's close above today's midpoint

and [close > low + [range * .5 ] ]

today's close below today's midpoint

and [close < low + [range * .5] ]

To find today's close between yesterday's open and yesterday's close is more complicated.

You need to account for two possible situations: was yesterday's close greater than (above) yesterday's open?

or was yesterday's close less than (below) yesterday's open?

and

[ // yesterday closed above open

[

[ 1 day ago close > 1 day ago open]

and [ close < 1 day ago close]

and [close > 1 day ago open]

]

or

// yesterday closed below open

[

[ 1 day ago close < 1 day ago open]

and [close > 1 day ago close]

and [close < 1 day ago open]

]

]

The distance between two points is a difference.

Range is the distance between the high and the low, so you have to subtract.

For a short wick (small shadow above the body) either the close or the open needs to be near the high.

// wicks - shadow above the body

and

[

[ // close near high

[close < high - [range * .1]]

and [close > high - [range * .2]]

]

or

[ // open near high

[open < high - [range * .1]]

and [open > high- [range * .2]]

]

]

For a short tail (small shadow below the body) either the close or the open needs to be near the low.

// tails - shadow below body

and

[ // close near low

[ [close > low + [range * .1]]

and [close < low + [range * .2]]

]

or

[ // open near low

[open > low + [range * .1]]

and [open < low + [range * .2]]

]

]

You need all the parentheses exactly as shown or you will get an error from the syntax checker.