#### Howdy, Stranger!

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

# Can anyone write this scan syntax?

I need a scan syntax and being a novice I have no idea what I am doing.

Here is the scan I'm trying to write:

A stock makes a 52-day high and after that for 3, 4, 5, 6 or 7 consecutive days the stock makes lower highs.

That's it! It seems simple enough but being a notice I have no idea how to write it.

Can anyone write that?

• mod
Well, it's more complicated than you might think.

You have five different cases:

52 week high 4 days ago then 3 consecutive lower highs
52 week high 5 days ago then 4
52 week high 6 days ago then 5
etc.

Each of those has to be coded separately.

The first one would be:

and [4 days ago high = 4 days ago max(251,high)]
and [Streak Down(high) = 3]

For the next one, you have to adjust the numbers for 5 days ago, etc.

and [5 days ago high = 5 days ago max(251,high)]
and [Streak Down(high) = 4]

If you want all the cases in one scan, you have to link them together in an "or" statement:

// begin scan

[exchange is NYSE] // or whatever

and

[ // begin or statement

[ [4 days ago high = 4 days ago max(251,high)]
and [Streak Downn(high) = 3]]

or

[
and [5 days ago high = 5 days ago max(251,high)]
and [Streak Downn(high) = 4]
]

or

etc.

] // end or statement

// end scan

When you write it yourself, just do one case at a time starting with the first, then add the second, etc.

Stockcharts has made it easier and easier to write scans, but they don't write themselves. You will have to put some time in if you want to master it. You could start here: