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.

writing scans

im not familiar with how to write scans in stockcharts.com and I'm hoping someone could lead me on the right tracks what i would like to do is find stocks that have recently broken out to either a recent new high or a recent new low ...but what I'm looking for are the false breakouts the stocks that start sink back down after making a new high, or stocks that have started going back up in price after making a new low......basically how would i scan for false breakouts both to the upside and to the down side?

Best Answer

  • markdmarkd mod
    Answer ✓
    The available "groups" that correspond to indices are listed in the Indexes and ETFs drop down on the Advanced Scan workbench in the Scan Builder section. Select one and click Insert.

Answers

  • markdmarkd mod
    edited March 2016
    Hi @conquer1 , the hard part of scan writing is not the syntax, but deciding what you want the scan to do. The scan engine needs to have very specific conditions to look for, or it doesn't know what you want. Unfortunately, it doesn't understand what a breakout is, so you have to tell it what you mean. In a way, that's good, because it makes us look closer at things to understand them better.

    So for your scan, what do you think of as a breakout? When you look at a chart, how would you describe it in plain english (we can get to scan language later)? In other words, how would you define it in terms of an overlay or indicator that you've put on a chart? You'll probably find many different kinds of breakouts, but choose just one to start. Once you have that, then we can start writing a scan for the first part.
  • i was thinking of when i see price has made a new high but within the next day or 2 start to fall again (for a false upside breakout) , it would be oppisite for a false downside breakout ,price would fall to a new low ,but a day or 2 later start to turn back up again...if i had to use an indicator i would guess macd histogram and i'm thinking i would be looking for the fist tic down of macd histogram after a break out for upside break out and the first up tick in macd histogram for false downside breakouts . Again this is just a thougt im still trying to get my mind to think as a serious trader
  • It's a bit hard to believe but here I am a newbie to stockcharts writing a comment to another newbie. My suggestion is to spend plenty of time on a chart(s) that interests you, select a time frame that you want and try all the indicators, MAs, etc. on that chart page as you look for what you want. I find it's a great way to see what you want before delving into scan writing. Markd suggested Fast Stochastics and I fully agree. Excellent for nailing changes.
    Best of luck,
    Hayden
  • Hi @conquer1 , for identifying a breakout I would suggest looking at Price Channels overlays of different lengths - so maybe 5, 10, 15, 20, etc. days, or any numbers in between. Which channels are broken most often when you see the kind of new high you are looking for?

    NOTE: the price channel you want should go straight back to the past high or low that price is now breaking - if too much time goes by, the price channel line will rise or drop so it is no longer at the same level of a past high or low.

    @hayden1059 's suggestions are worthwhile also, although I think it's good that you have focused on breakouts. It helps to concentrate on getting one thing down.
  • @markd are you saying i should use ema, keltner channels, ect....... play with the numbers of them then see which breakouts i like? And see at what numbers fit the best ?
  • markdmarkd mod
    edited March 2016
    I assumed by breakout you meant closing beyond a past top or bottom. I thought price channels would capture that best.

    But now I realize breakout could also mean a close beyond an MA envelope or as you suggested, a Keltner channel.

    Any of those is fine if it fits your needs. For writing the scan, you just have to decide which kind of breakout you want to capture - which overlay do you want to use (Price Channel, Keltner, MA envelope) and what are the parameters you want to plug in. If the default parameters work well enough, we can use those.
  • conquer1conquer1
    edited March 2016
    my ultimate goal right now is to see a chart with

    2 peaks with the second peak higher then the first at the same time I would like to see macd histogram make a lower high then the previous rally causing a bullish divergence............I would like for the opposite in down trends..i hope that explanation helps

    I want to fade the false breakout of the second peak

    you were correct about your assumption. I did mean a close beyond a previous top or bottom..ive never used price channels I just use keltner channels with default settings
  • OK. So how are far apart are those peaks. Not more than how many bars (trading days)?
  • I was thinking between 5 and 20 days no more than 20 no less then 5 for me to start with...do you have any suggestions i would be happy to hear them i know i have to "find my way trading" , but im definitely open to suggestions.
  • markdmarkd mod
    edited March 2016
    OK. So I think the easy way to do this is to write two scans, the first to capture the breakout, the second to run next day or two or three against the results of the first to capture the MACD Hist. So there will be four scans altogether - two for the upside, two for the downside. I'll give you the upside, then you can copy them to a new scan and edit for the downside.

    So the upside breakout scan would be something like

    // begin upside breakout scan

    // define universe

    [group is sp500] // change this to your preference

    // Check for flat Upper Price Channel line for the last 10 (or some number) of days

    and [ 1 day ago Upper Price Chan(21) = 10 days ago Upper Price Chan(21)]

    // today breaks above the Upper Price Channel

    and [close > 1 day ago Upper Price Chan(21)]

    // end breakout scan

    The downside breakout scan would be similar, but you would change Upper to Lower, and ">" to "<".

    Put these results in a list and name it.

    *****

    Now the MACD Hist scan for drop after upside breakout:

    // begin MACD Hist drop scan

    // to define universe:
    // from the "Chart lists" drop down in the Scan Builder section
    // of the advanced scan page
    // choose your results list from the scan above and insert it.
    // It goes to the bottom of the scan window.

    // Cut this next line and paste in your list name:

    [favorites list is ??] // your list name here

    // check for current MACD Hist bar less than prior Hist bar

    and [MACD Hist(12,26,9) < 1 day ago MACD Hist(12,26,9)]

    // end MACD Hist drop scan

    Now you need a second MACD scan for the downside breakouts.

    It will be the same as this one, except you will run it against your list for down side breakouts, and change the "<" to ">" (because when the Hist is negative, smaller negative number values of shorter bars are mathematically greater, e.g. -2 is greater than -3).

    *****

    Note: you can play with any of the parameters or number of days ago to see what happens.
    You can remove any line that begins "//" without hurting anything.


    Hope that helps.
  • yes it was helpful. sorry about the late reply i'm just now getting to try this out.
    what if i wanted to change the universe how do i go about doing that lets say i wanted to use the russell2000 ,nasdaq, or wilshire 5000

    thanks for your help in advanced
  • Just to add to @Markd 's excellent comments here's a couple of other options for which the details are covered in the scanning documentation and tutorials.

    You can also combine several individual groups to cover a larger group. Say you wanted the S&P 1500, just use an "OR" condition with an extra set of brackets to contain the OR's just to this line.

    and [ [ group is SP500 ] or [ group is SP400 ] or [ group is SP600 ] ]

    Now for exchanges these are listed under Ticker properties, again these are all listed in the documentation, see the link to instructions at the bottom of the scan page or review all the documentation under the ChartSchool tab on the home page.

    Exchange: The exchange that each stock trades on - “NYSE”, “NASDAQ”, “OTCMKT”, “OTCBB”, “PINK”, “AMEX”, “TSE”, “VENTURE”, “NSE”, or “LSE”


    and [exchange is NASDAQ]
  • thank you both for your replies they were both helpful for me....how ever the more i go over this in my head maybe i need to change it up a little bit I've noticed that when i look at stocks the breakouts i notice the most in hindsight would be the ones that were made in a quarter like it would be a breakout to a new high or new low for the last 3 4 months is there any way to find those kinds of stocks on a chart then i could maybe adjust it later on to include longer or shorter time frames as needed/wanted i.e. new hi for past 6 maths or new hi for the past 30 days? thanks for the help in advanced
  • markdmarkd mod
    edited April 2016
    Hi @conquer1 , well, I think you are following the normal path - you have an idea, you try it out, and then you want to narrow it down to make it better.

    If I'm understanding you, I think you can just take the up side/down side breakout scan above and change the length of the price channel - say from 21 - which is about a month - to 63, which is about a quarter (3 months). Price Channels are a great way to find breakouts. Or, you can choose an arbitrary number for the channel length, like 43 or 78 - or any other number you want and see what happens.

    Then you can change the length of time the channel has been flat - from 10 days ago to maybe 45 days ago, or some other number a little shorter than the channel length you choose. Just look at your past examples - add the Price Channel indicator to your chart style. Maybe add several to see how they work (I have 4 - which some people might think is overkill - based on calendar intervals - 10 days (which is two weeks - half a lunar cycle, but we won't get into that), 21 (a month), 63 (a quarter) and 251 (a year). I like them for reversals, usually within a trend (for example, getting near a 10 or 21 day low when the longer trend (moving average) is rising), but they can work for breakouts, too.

    Remember, you have total freedom to structure the scan anyway you want to find what works better for you. It's all a matter of experimentation, which you seem to be getting the hang of quite well.
Sign In or Register to comment.