Scanning Technically

Why Do My "After the Close" Scan Results Change ??

Q: Why do I get different results when I run a scan at the close, a few minutes later and then a few hours later.  The scan criteria is the same and the mathematical formulas are the same.  How can the timing of my after the close scan change the math and give me different results ?

A:  Very good question, it doesn't happen often but if you run alot of scans you will occasionally come across this situation.  There are multiple reasons for this, lets look at some of the common causes.  Note this is only a general overview of the basics.


1) Alot happens right at the close and within the next few minutes, the exchanges are very busy trying to accurately close out the day before after hours trading begins.

 - The books are balanced, any errors are corrected and the closing price is set.
 - All the EOD (trade at close) orders, account swaps, EOD block trades etc are processed, this won't change the closing price but it will change the volume.
 - The shareholders of record are determined, this is important for the distribution of dividends or splits etc which will be occuring EOD for specific stocks.
 - Official EOD numbers are set.

All of the above should happen before the after hours trading market opens.

2) Stockcharts begins their updates after step 1 is complete.

 - Once the official numbers are released Stockcharts can then start updating their databases.
 - For stocks which have gone EX dividend the historic data will be adjusted
 - For stock spits or consolidations the historic price and volume are adjusted

All of the above is done manually and may take a couple of hours depending on the volume of adjustments.  The end of the month and in particular end of the quarter tend to be very busy times for dividend & split adjustments.

For recent data adjustments you can check the "Recent Data Adjustments" link on the right side of the FreeCharts page under the "Other Tools" menu.

http://stockcharts.com/freecharts/adjusthist.html

For more indepth reading on data accuracy see this article.

http://blogs.stockcharts.com/chartwatchers/2012/07/on-data-accuracy-at-stockchartscom.html

Thus in summary when running scans just after the close, a few minutes later or even several hours later be careful how you interpret the results.  The math doesn't change but the underlying databases used for the calculations can change.  The closing price is the same however the closing volume may change and with dividend adjustments the historic prices and volume may also change.  These changes will also affect the values calculated for the indicators and overlays which are contained in your scan, which is why the results may occasionally change during this period between the close and completion of all the update adjustments. 

cheers Gord



Writing a Scan, How Does "YOUR" Mind Think ??

** Updated April 5, 2014  see addendum notes.

Have you ever read the scanning documentation or reviewed someone else's scan coding and thought this  just doesn't make sense to me, well you are not alone it happens to all of us.  We are not identical computers running the same version of software, we are individual, (and thats a good thing).

Scans are mathematical relationships between various variables and by default we all think of those relationships a little differently.  Here's a few examples to get you thinking outside of "YOUR" box.

In the following case A is greater than B, but from the other side B is less than A, what was Your first thought?

A B blocks

Now lets review some of the mathematical relationships between A & B and the various ways we could write them.  Remember mathematical relationships are usually read from left to right, ie A is greater than B, (A > B) however the converse is also true, as read right to left, ie B is less than A, (B < A).  Here's a table of just a few of the relationships we could write about the A & B example shown above.  Note they all describe the same thing, just stated in different ways from a different point of reference and if used in a scan they would all yield the same results.

Math formulas

Now lets apply this to a couple of chart scan examples and we'll be looking for < or >, rather than = , and we'll also replace A & B with actual technical variables.

1- Looking for todays close to be more than 25% above todays SMA-50 of the close.  [ A > B * 1.25 ]

    and [Close > SMA(50, Close) * 1.25]

This is the chartstyle I would use for laying out the scan and maybe a slightly shorter period for checking the scan.  Note the use of the SMA envelopes to easily see the +/- 25% lines around the SMA-50

http://stockcharts.com/h-sc/ui?s=MPAA&p=D&st=2013-04-18&en=2014-02-14&id=p70098512834&a=336935179

Chart close 125%

2- Or looking for the same thing using a different formula we could use the following.  [ A < B * 0.8 ]

   
and [SMA(50, Close) < Close * 0.8 ]

Similar layout and checking chart, although in this case we are looking for the +/- 20% lines around the closing price.  We can still use the SMA envelopes, the trick is to set the SMA to a value of 1 period, (ie the close).

http://stockcharts.com/h-sc/ui?s=MPAA&p=D&st=2013-04-18&en=2014-02-14&id=p30976225021&a=336939351

Chart close 80%

So in summary there is almost always more than one way to write a scan.  I like " [ A > B * 1.25]", but some like to see it as " [ B * 1.25 <  A ]" or "[ A * 0.8 > B ]", all depends on how "Your" mind thinks.  Just get comfortable with your prefered format and when you save someone else's scan for future reference just modify it to your way of thinking and maybe add a few comment notes.

happy scanning

Gord

 --------------------------------------------------------

** Addendum notes, additional details

With my engineering background I have been working with mathematical relationships for over 50 years, thus the above comes easily without even thinking about it.  However if this is not your background you may find these extra notes will help get you on the right track.

 Part I, defining the relationship graphically

First when thinking about mathematical relationships define a scale that works for you in determining the relationship graphically.  It doesn't really matter what scale as long as you use the same one for both sides, A&B.  Then ignore the greater than or less than signs, just work on how to make them equal, you can move on to the , < or > signs later.

1) Lets start with numbering the blocks 1, thru 5.  Thus if A is 5 blocks and B is 4 blocks, then we could write the equation, A times 4/5 = B.   Looking at it from the other side if B is 4 blocks and A is 5 blocks, we could write B times 5/4 = A.

                        A * 4/5 = B                 B * 5/4 = A

Now lets simplify this a bit,  4/5 = 0.8   and  5/4 = 1.25,  so the above can be rewritten as;

                        A * 0.8 = B                 B * 1.25 = A

2) Lets try a different scale numbering system, we'll make the value of A = 100, thus the five blocks of A become 20, 40, 60, 80, 100 and using this scale B = 80.  Thus the relationship could be written as A times 80/100 = B  or B times 100/80 = A.

                        A * 80/100 = B           B * 100/80 = A

Again lets simplify this a bit,  80/100 = 0.8   and  100/80 = 1.25,  so the above can be rewritten as;

                         A * 0.8 = B                 B * 1.25 = A

3) Lets try a different scale numbering system, this time we'll make the value of B = 100, thus the four blocks of B become 25, 50, 75, 100 and using this scale A = 125.  Thus the relationship could be written as B times 125/100 = A  or A times 100/125 = B.

                        B * 125/100 = A         A * 100/125 = B

Again lets simplify this a bit,  125/100 = 1.25   and  100/125 = 0.8,  so the above can be rewritten as;

                        B * 1.25 = A               A * 0.8 = B

Notice how even when using different scales, the mathematical relationships still simplify to the same basic formulas.  The scaling method you use just depends on which way your mind likes to think and whether you want to define A in terms of B, or B in terms of A.

Now you may also want to brush up on a little high school Algebra, just Google it there are lots of tutorials.  But basic Algebra also lets us manipulate the formulas once we have one valid relationship.

The basic premise is that as long as we do the same thing to both sides of the equation, the equation is still valid.  So lets start with;

            B * 1.25 = A

Divide both sides by 1.25

  B * 1.25 /1.25 =   A / 1.25     simplify    B * 1 =   A /1.25  simplify    B  = A * 0.8   or   A * 0.8 = B             

So again we arrive back at the same formulas we developed graphically above but this time we've used some basic algebraic manipulation.  I could continue, but I'll let you do your own DD.

Part II, the charts used for verifying and troubleshooting the scan.

I find when verifying and troubleshooting a scan, the quickest and easiest way is to create a chartstyle that highlights only what is in the scan.  This is not a chartstyle I would use for Technical Analysis, its focused on just the scan parameters I want to verify and I want to see them graphically so I can visually check at least 50 charts in a few seconds without having to look and compare individual numbers on each chart.

Limit the chartstyle to only the key parameters in the scan.  If the scan involves things that happened in the last 5 days, do not look at a 12 month chart, look at a 10 day chart.

Use indicators and overlays set up to highlight the parameters of your scan, performance charts are also helpful when the scan involves percent change.

For review I use the 10 per page view and I can quickly scroll thru 50 charts in a couple of minutes.  If the scan is fairly simple and the parameters can be seen on a small chart I'll save a CandleGlance chartstyle and then can review 30 charts per page quickly.

Cheers Gord

Scanning to Find Stocks with Selling Climaxes



A selling climax occurs when a stock falls sharply on extremely high volume. As the name infers, a selling climax suggests that selling pressure has peaked and traders should expect some sort of rebound. Think of this selling pressure as a stretched rubber band, which cannot stretch forever. At some point, the rubber band either breaks or snaps back. In chart terms, a rubber band break would be the equivalent of a complete meltdown in prices. A snap back implies an oversold bounce that retraces a portion of the prior decline.

With a high-volume decline over the last few weeks, several stocks have experienced selling climaxes that could give way to oversold bounces. Though not perfect, chartists can find some these stocks by devising a scan to capture this high volume decline. The scan criteria below are designed to find stocks that became oversold on high volume and are still trading near their lows. Chartists can copy and paste this code into the advanced scan workbench.

[type = stock] AND
[country = US] AND
[Daily SMA(20,Daily Close) > 10] AND
[Daily SMA(20,Daily Volume) > 40000] AND
[Daily SMA(2,Daily Volume) > Daily SMA(250,Daily Volume) * 2] AND
[BB Width(10,2) > Daily SMA(250,BB Width(10,2)) * 2] AND
[Daily MIN(5,RSI(14)) < 25] AND
[Fast Stoch %K(14,3) < 10]

The first four lines simply qualify the symbol universe. The type is set for stocks, the country is the US, the 20-day price average is above $10 and the 20-day volume average is above 40,000 shares.

[Daily SMA(2,Daily Volume) > (Daily SMA(250,Daily Volume) * 2)]
Line four looks for stocks where the average volume of the last two days is at least twice the 250-day average for volume. This insures extremely high volume.

[BB Width(10,2) > Daily SMA(250,BB Width(10,2)) * 2]
Bollinger Band Width is a measure of volatility. In this example, we are looking for the BB Width (10,2) to be at least twice the 250-day average of BB Width (10,2). This insures that we have seen an expansion in volatility.   

[Daily MIN(5,RSI(14)) < 25]
Line six looks for stocks where 14-day RSI dipped below 25 at some points in the last five days. This insures that the stock moved lower and became oversold over a 14-day period, not just for a few days. Note that 30 is normally used for oversold readings. Using 25 insures an extra degree of oversold-ness.

[Fast Stoch %K(14,3) < 10]
Line seven looks for stocks with the Fast Stochastic Oscillator below. The Stochastic Oscillator measures the level of the close relative to the high-low range over the last fourteen days. A Stochastic Oscillator below 10 insures that the current close is near the low end of this range. This last criterion is used to cancel out stocks that have already bounced.

140206whr780
Click this image for a live chart

The chart above shows Whirlpool (WHR) meeting these scan requirements on Monday, February 3rd. Notice that WHR did not meet these requirements with the big decline two days earlier. Even though volume and the Stochastic Oscillator met the requirements, RSI did not break below 25 to confirm an oversold condition. Keep in mind that these are just guidelines and chartists can tweak the settings to fit their scanning needs.

What's Wrong with this Scan ?? Bearish MACD Crossover

 
Question:

I inserted a predefined scan in the advanced scan workbench for a "Bearish MACD Crossover", however I'm not sure it's right.  I just cleared out all the default criteria and then selected and inserted the predefined Bearish MACD Crossover.  Here is the actual coding.

Scan code

 The coding seems to make sense until the last line which I think may contain some typos.  I understand there is a numerical relationship between signal and line, but what is the relationship between signal and histogram?  Also could someone explain what *0.25 means in the last line…  thanks.

 Answer:

 Actually this scan is correct for what it's doing, it's just a little more sofisticated than a basic crossover scan. In its simpilest form the scan could be just the first 4 lines.   However in this case, to eliminate picking up weak crossovers the scan adds the last 3 lines to ensure some stability and actual separation of the line and signal before the cross.  Note you can also modify this scan to suit your own needs and save it to your scan list.

 First lets be clear on what the MACD Histogram is.  It's just the numerical difference between the MACD Line and the MACD Signal, but it's plotted as a bar histogram along the "zero" line.  Here's a graphical representation.

MACD Hist
 
Now lets look at a graphical presentation of the whole scan, I find it often makes more sense than just looking at the math coding.  I've annotated each line of the code onto the chart for each of the days in the past.

Bear MACD cross

 Now lets look at the coding in question, the last line.

 and [3 days ago macd hist > 3 days ago macd signal * 0.25]

 Remember the Histogram is just the difference between the Line and the Signal, in this case we want some significant separation, ie 25%.  Still confused ? how about if the last line was coded differently, like the following.

 and [3 days ago macd line > 3 days ago macd signal * 1.25]

 For many users this might seem to make more sense, however its the same as the previous line, just stated in a different way, (getting from one to the other just takes a little algebra).  Our minds all think a little differently and what is the default for one person, seems backwards or just plain confusing to another.  It all depends on how you view numerical relationships.  Some people think "A" is BIGGER than "b", while others will instantly think "b" is smaller than "A".

Looking at just the last line here is a graphical representation of 4 different ways the same coding could be written, (and there are more).

MACD to Signal var

 Now for those who are still not sure, here's the algebra behind how we get from one coding line to the next.

  Algebraic

 I hope this  gives you a different view on the subject of scanning and writing code.

 cheers Gord

How can I see exactly what a predefined scan is doing and can I modify it ?

 Well the short answer is yes, if you have an Extra level subscription or higher.  Basic or Free members can only review the output list of predefined scans.

 In the Standard Scan workbench there are two ways to add a predefined scan.

 1 - Under the "Global Filters" section just select the predefined scan in the drop down box.  This will add only the filter title, it does not show you the coding details and does not allow modifications.

or

2 - Under the "Additional Technical Expressions" section, select and insert the scan.  This is the method you want in order to see the coding details and allows you to modify them.

Method 1

1
 Method 2  2As you can see the coding is inserted in the "Technical Expression" workbench section and also displayed in the Criteria summary at the top.

 • 50-day Simple Moving Average of Close for today is greater than 200-day Simple Moving Average of Close for today
• 50-day Simple Moving Average of Close for yesterday is less than or equal to 200-day Simple Moving Average of Close for yesterday

Now you might notice that this is the long hand version of the cross-over function, "X" and this scan could have been written more simply as shown below.  3

 However the long version offers us a few more options.  Say you really want something on a little shorter time frame, the SMA-20 crossing above the SMA-50, well just change the 50 & 200 to 20 & 50.

4

But we only want crossovers that are significant, not the ones in the noise level that are bouncing around and crossing by tiny tiny amounts.

 Lets say rather than just being greater than today, we want the SMA-20 to be at least 1% greater.  So we would multiply the SMA-50 by 1.01 which will add some significance to the cross.

 Now we could also modify the pre-cross section to ensure that it was significantly below in the past.  Lets go back 2 days instead of 1 and require the SMA-20 to be at least 1% less than the SMA-50 at that point.  So we would change the 1Days to 2Days and multiply the SMA-50 by 0.99 (which reduces it by 1%)  6

When I ran this scan as of the close Jan 9th 2014, the modifications narrowed the hits from 113 to 18.

 Finally one of the best ways to review, analyze and verify your scan is to look at it graphically.  This is also a great method to use when planning out and developing a scan as it helps visualize breaking up a large scan into smaller sections of code.  5

http://stockcharts.com/h-sc/ui?s=END&p=D&st=2013-12-13&en=2014-01-09&id=p81238557250&a=331269852

Happy scanning and always verify your scan outputs with a review of the charts, as what you think you asked for is not always what you really asked for. 

Gord Greer

 

Modify, Develop and Test a Custom Scan

Some of you might recognize this example from a CSTA webinar I did last Dec, but I thought it was a good time to update and share it with all StockCharts users.  The example starts with a simple predefined scan and shows how it can be modified, step by step.

(Note the techniques described use the advanced scan interface for writing custom scans, thus you will require at least an Extra level membership to create these scans).

When reviewing the charts for the S&P500 index we see that the index closed above the Feb and April levels.  Now individual stocks don't always follow the index exactly but we can use the scan engine to find which are leading or lagging the index.  Also we have to be aware that the $SPX is the S&P 500 market cap weighted index, ie Exxon and Apple account for 6% of the index.  We could also look at the $SPXEW which is the equal weighted S&P-500 index where each of the 500 stocks accounts for 0.2%, this index exceeded the Feb highs in April and exceeded the April highs today.

SPX SPXEW

So lets find out how the individual stocks in the index are doing.  We'll limit our initial scan to the S&P-500 and insert one of the predefined scans "New 52 week high".

1 input

Now running this scan yields 98 hits, but I'm more interested in closing values than the daily highs and really only interested in looking back into Jan.  Now we could change only todays high to a close above the previous intra-day high but in this case I'll change both the "highs" to "close" and just look for the previous maximum back say 90 days instead of 260 trading days.

[type = stock]
and [group is SP500]
and [today's close > yesterday's daily max(90,close)]

This gives us 113 hits. 
But I know some stocks in the index may not have had a new high close today, they may have had a new high a few days ago and pulled back a few cents today.  So lets look for a new high close anytime during say the last 5 days which is higher than the highest close for the previous 90 days (starting 6 days ago).

[type = stock]
and [group is SP500]
and [max(5, close) > 6 days ago daily max(90,close)]

This gives us 163 hits, which corresponds to 32% of the stocks in the S&P-500 hitting a recent new high close in the last 5 days.  But I'm also interested in what the Small and Mid cap stocks are doing so I'll add them to the list and by using the comment prefix of // or #, we can turn these individual clauses ON and OFF.  (any line prefixed with // or # is considered a comment and not evaluated)

[type = stock]
// and [group is SP500]
and [group is SP400]
// and [group is SP600]
and [max(5, close) > 6 days ago daily max(90,close)] 

This yields the following hits;
SP500,  163
SP400,  113
SP600,  111
Total =  387

Now we also have another option if we wanted to look at the Large, Mid and Small caps simultaneously, we could create a grouped "OR" clause, enclosed by an extra set of square brackets.  Note this function is only available in the advanced scan engine interface and I have turned OFF the individual clauses.  (Note the S&P-1500 is currently not available in the scan engine as a predefined group, but you can chart it under the symbol $SPSUPX)

[type = stock]
// and [group is SP500]
// and [group is SP400]
// and [group is SP600]
and [ [group is SP500] or [group is SP400] or [group is SP600] ] 
and [max(5, close) > 6 days ago daily max(90,close)] 

This gives us the same 387 hits as the individual scans.

Now if we look at the $SPXEW-500 Equal Weight index, we see that it is about 1% above its recent highs, so lets limit our scan to only stocks which significantly exceed that.  Lets try 5% above the past highs and lets use the S&P-1500 group, (use the multiplier function).

[type = stock]
//and [group is SP500]
//and [group is SP400]
//and [group is SP600]
and [[group is SP500] or [group is SP400] or [group is SP600]]
and [max(5, close) > 6 days ago daily max(90,close) * 1.05

This gives us 45 hits.

In summary I verify each section (clause) before proceeding to the next clause.  I find the quickest way is to review 10-20 charts to see if they meet the scan criteria and I try to make this as visual as possible, (its just quicker).  So before I run the scan I set up a simple chart for only the time frame of the scan and only plot what the scan is looking for.  In this case the chart covers Feb till now and is a performance type chart which makes the min 5% gain easy to see.  I save this chart as my default style and after I run my scan I can easily dump the output into my "00 Temp" fav list (it’s the first list so its already in the drop down box, just hit go) and all the charts will be created with this chart style. 

Note; if for some reason you need to keep your default chart style you can also change the chart style after you have dumped the group to a new fav list, just set up a new style on one of the charts and then use the "Apply Style to All" button, but this will take a few more steps and you will have to redo those steps every time you run and dump new scan results.

1 output

At this point you can also click on the table headers and sort by "Sector" or "Industry" to see where most of the hits are coming from.


Then select the 10 per page view and quickly scroll thru 10-20 charts to verify the scan is finding what you asked for, or what you thought you asked for.   If necessary go back and modify the coding.  Then select differnt indexes or add more specific technical criteria.

2 output

The following is a graphical representation of the scan which is often helpful when developing and laying out scans, especially the more complicated ones.

Scan graphic

I hope this discussion has given you some new ideas on creating, modifying and testing your own customs scans.

Happy scanning,

Gord

(note: I don't work for StockCharts, I'm just a long time user always trying to learn more and willing to share what I've already learned.  If you have comments related to this article I'll try to answer them here, if you have other comments or suggestions send them directly to StockCharts thru the support page). .

 

Is It Possible to Change the Default Scan Definitions?

 

Right now, whenever I open up the Advanced Scan Workbench, I get this default benchmark definition for the universe of securities to scan:

[type = stock] and [daily sma(20,daily volume) > 40000]

This is hopelessly broad in that it includes boatloads of thinly traded stocks, penny stocks, foreign stocks and the like — securities I would never trade in, myself. I have my own definition of a securities universe, which looks like this:

[type = stock] and [[exchange is NYSE] or [exchange is AMEX] or
[exchange is NASDAQ]] and [daily sma(50,daily volume) > 200000] and [Close > 10]

This is my personal universe, and it works for me, but the point is, I would like to change the default securities universe to be that, rather than forcing me to manually change the overly broad universe that's already baked in, every time I log in.

Is there a way to make that change?

chasfh

  

The short answer is “No.” The default scan page isn't customizable.

However, there is a workaround. You just have to change how you access the scan engine. Normally, I use the links on the Members page. You can use the right-hand link to “Create a New Scan,” which takes you to the Standard Scan Workbench. Then you hit the Advanced Scan button to get to the Advanced Scan Workbench page with the standard default starting point.

There is another link on the left, though, that you can use to pull up one of your saved scans and run it or edit it. This is the method I use, as I am either running a saved scan, editing a saved scan, or creating a new scan from scratch. Why not have the scan engine open directly in the scan where you want it to be, rather than open the default and then pull up your saved scan?

For a new scan with “MY Standard Default” intro settings, I just pull up one of my standard intro templates. These are scans I've created with different default settings that I use as a starting points. Their names start with “0” so they are always at the top of the drop-down menu list.

Changedefaultscan

One more thing, its always good to put the primary database criteria first — Symbol, Open, High, Low, Close and Volume — and put the secondary calculated criteria second. Your scans will run faster if the heavy calculations are done after the universe of stocks has already been reduced.

In other words, don't ask the scan engine to calculate EMAs, Stochastics, and Bollinger data on the entire 30,000 stocks in the database, and then ask it to scan the results for stocks between $5 and $10. Make the pool of stocks to be scanned as small as possible first. Then, run the heavy calculations. Your scans will run much, much faster.

Cheers Gord

Gord

To see all the responses to this question, go to the original post on s.c.a.n.

How to Use the Elder Impulse System to Trade

 

To experienced users of the Elder Impulse system for trading: What parameters for entering and exiting a trade have you found most useful using this system. For example do you exit a trade immediately when the daily 13 day ema chart shows a change from a green price flag to a blue, or do you wait until a red price flag is generated or what?

JHuber8383

  

Before choosing chart settings, if you are an Elder follower, you will need your “Triple Screen.” I would suggest starting with hourly, daily and weekly. Personally, I just work from a feel for each chart. For my own trades, technically, I rely more on patterns, drawn lines, and fib level responses to price action (than the signals on the Elder Impulse). I saw a comment once from Elder that he uses 13, 65 and 200 EMA's, so I have been using that as a default chart for myself. Here is an example:


Zz-elderdaily

 

If there is a clear trend, then I favor ADX. If there is not, then I favor an oscillator like RSI. When I place indicators on the chart, I usually shift the setting towards fibonacci numbers (3, 5, 8, 13, 21, 34, 55, etc). For example, on the chart I posted above, the ADX trend is down and the RSI reading is still bearish. However, what is more impressive to me is that second Head and Shoulders pattern developing within the bearish flag and the confirmation of the bearish flag this last week. The next level to watch is the 2011 low near 10604 (kind of like an upside down break out) and then an A = C measured extension on a weekly chart. Here is the A = C extension on a weekly.

Z-elderweekly

Notice that the daily (your primary trading time frame) and weekly (your big picture) charts work together using the Elder-suggested Triple Screen. All you would need to do is form an hourly chart (e.g., your entry) for your trade. Most all of this is discussed in Elder's book, Come Into My Trading Room. However, he does not discuss patterns very much in that book.

Anonymous

To see all the responses to this question, go to the original post on s.c.a.n.

Scanning for Stocks that Outperform their Indexes

 

Is it possible to use the scan engine to pull out stocks contained within an index that are outperforming that index? I would like to run a scan for stocks in the S&P 500 that are outperforming the S&P 500 as a whole. Thanks!

relaycharger

 

Here is a link to an article I wrote for the Scanning blog which should answer your question with even a few more ideas you may not have thought of.

For those who don't want to follow the link, I'll give you just a couple of snippets from that article. The very simple scan was as follows.

(Note you could turn on or off any of the individual groups by removing the double //, or just us the clause with the "OR" conditions to get the whole S&P 1500 index.)

In this case, there where two previous Highs in the $SPX index some time ago, and we were looking for stocks in that index that had now, during the last 6 days, exceeded their previous Highs during that time and were also more than 5% higher than those previous Highs.

[type = stock]
//and [group is SP500]
//and [group is SP400]
//and [group is SP600] and
[[group is SP500] or [group is SP400] or [group is SP600]]
and [max(5, close) > 6 days ago daily max(90,close) * 1.05 ]

Now for these types of scans, it is often helpful to see it in graphical form, so here are the conditions and criteria which had to exist to satisfy the scan and return a result.

Gordscan

I hope this gives you some other ideas. If you find this interesting, please read the entire article which contains much more information.

Cheers!

Gord

To see all the responses to this question, go to the original post on s.c.a.n.

How to Scan for Stocks in an Uptrend Just as the 13-Day EMA Crosses Above the 26-Day EMA

 

I've been reading a lot and still haven't quite found the scan code I'm seeking. I'm looking for a scan that will bring up stocks at the beginning of an uptrend where the 13-Day EMA crosses above the 26-Day EMA.

As a side note, I follow the Elder Impuse System, and I like to trade within Keltner Channels.

I see a lot of crossover code on this forum, but when I run these scans, invariably, the stocks are already well into their uptrend and, sometimes, even too far above the 13-Day EMA for me to go long — so they just go into a watch list for a possible pullback to the 13/26 EMA zone.

So here is what I came up with:

[type = stock] and
[country = us] and
[daily volume > 500000] and
[close > 20.00] and
[close < ema(13)] and
[close >= ema(26)]

Can you help me tweak it so I get better results?

–BearTrader

 

Hi BearTrader,

A couple of comments. Are you matching your scan parameters to your trading time frame? If you want to capture the very beginning of a trend the 13 and 26 EMAs won't work because it takes quite a few days to turn them. On the other hand, once turned, they may be good choices for longer-term trades. If you want to get in early, you could try much shorter-term crossovers, e.g. 3x13,

and [ema(3,close) x ema(13,close)].

To get in even earlier, test for a Close crossing a falling EMA,

and [close x ema(13,close)] and [ema(13,close) < 5 days ago ema(13,close)].

To further put things in your favor, also test for a rising, longer-term moving average,

and [ema(50, close) > 10 days ago ema(50,close).

I've also noticed recently, although I haven't tested it extensively, that a Close above the lowest Open when the short-term MA is falling can be followed by a change of trend, sometimes after a test of the Low, so,

[group is sp500] and [ema(13,close) < 5 days ago ema(13,close)] and [close > open] and [close > 1 day ago min(7, open)].

A final note, I'm defining trend here really as a leg or a swing in a larger uptrend, assuming that's what your are looking for. Also, I've noticed higher-volume, higher-priced stocks tend to form more regular patterns (most of the time). If you want the lower-price bang for the buck, the percent changes for in-the-money options can be pretty good, although that cuts both ways.

–markd

To see all the responses to this question, go to the original post on s.c.a.n.

Other StockCharts Blogs