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.
Hello,
I am a newbie to stockcharts although I use Linnsoft IRT stock program. I am trying to adapt to the different scan languages.
I am developing a trading system that consists of identifying when a stock or ETF has bottomed, ideally on a 52 week scale, and then has risen subtly, by 2%.
Theoretically the idea seems very easy, but I would appreciate people's suggestions.
0
Comments
So for instance, you might specify that the minimum low over some period equals the current lower price channel
and [min(x, low) = min(x, Lower Price Chan(251))]
That tells you the most recent low has occurred within x days.
Then you would test that the maximum price in that time frame is less than 2% above the min Lower Price Chan:
and [max(y, high) < min(x, Lower Price Chan(251)) * 1.02]
I'm not sure whether it would work best if x and y are equal, or y a little shorter.
Like any language, the scan language must be written in a particular format, but the rules are few and very simple. There are just a few syntax requirements (mainly using the brackets to group statements - parentheses are for functions only - like max() and min().), and just a few functions and operators. There are no variables, no arrays, no memory management, etc.
If you haven't already, spend some time with the documentation available through the "Instructions" link at the bottom of the advanced scan page, or through the support page.
Also, look at the link "Understanding Scans" link (the page it links to is called "sample scans"). There are many samples of the most common types of scans. To get started, you could copy and paste and then edit these scans for your needs.
Also, make use of the drop downs below the advanced scan window. These contain all possible expressions in their default format. Just insert them in your scan as needed and edit.
If you get stuck, post the problem code and what you want to do in plain english. We'll take a look at it.
Your scan syntax is incorrect. Could not parse "X" located in the clause "MIN(X, LOW) = MIN(X, LOWER PRICE CHAN(251))" (an integer was expected)
Hayden
I enjoy your play on words with Markd, as in a marked man, but also assuming your first name is Mark.
I am used to the scan language of my stock trading program called Linnsoft IRT, a very complete program.
They have a scan function called SESST, short for session statistics. You open the SESST dialogue box in IRT and select, for example, the highest high, the lowest lo............ then you can choose different time periods for intraday to daily, weekly, monthly, quarter.
I found that using the Lowest Low for a quarter, IRT could give me a precise number and/or reference line of the lowest low for the quarter. That would work pefectly for the scan I am trying to write. And trying to figure out how to write that in stockcharts scan language.
An alternate method was to take a selection of stockcharts and draw red circles around the exact lows I am seeking. Sometimes there are double dips and noise, but I'll handle that with tight stops.
I have more markups if you wish.
Your help is much appreciated.
Hayden
You could use specific numbers - for instance, if you wanted stocks with a low between 50 and 60 in the last quarter, and now trading about 2% above their lows, you could write something like:
// begin scan
[type= stock]
and [country = US]
// lowest low in the last 63 daily bars (about one quarter) is between 50 and 60
and [min(63, low) > 50]
and [min(63, low) < 60]
// since the lowest low of the prior 63 bars, the close has advanced
// at least one per cent and not more than three per cent
and [max(63,close) > min(63,low) * 1.01]
and [max(63,close) < min(63,low) * 1.03]
// end scan
If you run this scan as of January 15, you get 13 hits (all etfs, as it turns out).
Here are a couple of the resulting charts. the straightish pairs of green lines are the 63 day Upper and Lower Price Channels.
For FMB, the lowest close (red circle) in the last 63 bars is between 1 and 3 per cent less than the current (January 15) close (blue circle), but it's been steadily rising. There was no dip to a quarterly low.
For CMBS, the lowest close (red circle) was also a 63 bar low as of the day it occurred.
If you want only the CMBS kind of situation, you need to specify where (roughly) the low occurred within the range of the PRIOR 63 bars.
The easy way (I think) to do that is to use Fast Stochastics to find where the close was within a price channel.
Use the first parameter to specify the length of the channel (63) and make the second parameter "1", so you don't get a signal line.
Then specify how low in the channel you want price to have gone, and how long ago that happened. So if you want price to have travelled within 20 per cent of the 63 bar price channel low within the last 21 bar (one month), you would write:
and [min(21, Fast Stoch %K(63,1)) < 20]
(Add this line at the end of the scan above, just above "// end scan", click check syntax, and set the date to January 15).
Now you will get only stocks (etfs actually, in this case) that bottomed in the last month and have advanced between 1 and 3 per cent.
You can fool around with any of the parameters, including the run date, to see how the results change.
Remember, the results come back with a chart in your default style, as of today's calendar date, NOT the date of the scan. So even if you set the scan run date for January 15, the charts will come back dated today. You also need to view the charts in a style that includes Price Channels and Fast Stochastics with the appropriate parameters to verify the results.
The scan engine returns only symbols, not specific prices or counts or other data. There are no variables to store any kind of data.
Price Channels are drawn from highs and lows, not closes, but Fast Stochastics is calculated using closing data. So the red circles on the charts above are not exactly right - they indicate the lowest lows instead of the lowest closes. Sorry for the confusion. The lowest close and lowest low are often, but not always pretty close together, so I've gotten to think of them interchangeably, which is not completely accurate.
As an aside, and as you might have noticed on these two charts, if the Fast Stoch %K(63,1) gets under 20 and the longer term trend is up (rising 251MA on these charts), then a worthwhile low is often nearby, either in time or price or both.
I do appreciate your patience and thoroughness in responding.
I will look into your suggestions to get a better grasp of what Stockcharts can do.
I suppose any chance of Stockcharts adding true SESST functionality would be a pipe dream (I dug that cliche out of very old memory banks, suddenly I see that it touches on "What have you been smoking.?")
The notion of entering the price range for every stock/ETF that interests me would be way too time consuming.
Interestingly I listened to Dr. Chande's webinar with Chip and have been exploring his site, ETFmeter. I can find excellent candidates based on his rankings and then jump back to SC to see how they look.
I'd like to specify that finding the historic lowest lows is not the goal. BOIL is currently in an ideal position of scraping the bottom so it is a candidate for me to watch for hitting a sweet spot of a small but significant rise in price, intraday would be excellent.
I'm glad you found Dr. Chande's site helpful.
If you wanted to find instruments trading at the lows of some time frame, you can do it with the Fast Stochastic I described above. You would just change the first parameter for the time frame that interests you.
For instance, if you wanted to pick up ETFs trading around their annual lows, you could write something like
[group is ETF]
and [Fast Stoch %K(251, 1) < 20]
This gets 180 hits as of Friday close 3/4/16. BOIL is one of those hits.
Here is the chart. The gold line is the Fast Stoch 251 (above the chart with three other Fast Stochs for smaller time frames (fourth window from the top).
A way to find bouncing stocks would be to test for the Fast Stoch 10 above 50 or 80 (see the blue Fast Stoch line on BOIL below- there are several bounces).
Also, note that BOIL is showing accumulation in the Force 251 (third window above the chart) - Force line is rising as price falls.
(I know these charts are busy, but you can always strip out -or substitute, or add - anything to meet your own needs.)
So if you want to explore outside of ETFs, you could do that with SC.
Thanks for your patience and help. I hope I'm not driving you nuts. I'm also glad to have signed up for the Stockcharts subscription, the price feels very fair for the information available.
I will start trying out your scan suggestions soon. Crowded, dense charts don't scare me that much, but the Stockcharts site - that is an upward learning curve that has me huffing and puffing.
I have been looking at the PerfCharts style option. Can this baby be scanned? I see that the price is below -80%. I wouldn't want to touch it until it has risen at least above -80%. Maybe you have an opinion about a Perfchart being misleading somehow,
I think a good way to approach it would be to pick up a book on technical analysis (or go back to one you've read already), choose one or two indicators to start, make a chart style that includes those indicators, make a favorites list of stocks, or use a predefined group like [group is sp500] and then look over the list for situations you would have liked to trade. What were the indicators doing where you would have entered? Put those conditions in a scan and see if you can pick up those stocks.
In other words, what you need is an idea of what makes a favorable trading situation.
Just as an example, and not a recommendation, my own charts are set up for:
RS - relative strength, as expressed by a ratio of two symbols using the "Price" indicator (top window of BOIL chart). I overlay four ratios in one window for sector to market, industry to sector, symbol to industry, symbol to market. This is similar to a Perfchart.
SCTR - another form of RS
Force Index - accumulation and distribution. Rising index shows stock is being taken off the market - when price falls and this happens, the divergence suggest a bottom is approaching, although it could take some time. A falling index shows stock is coming into the market. If price is rising, that suggests a top is due. Currently investigating whether the MAs are useful timing tools.
Fast Stoch - support and resistance. Stoch lines crossing 20, 50 and 80 are often support or resistance. Look for reversal patterns in price and volume bars - i.e. big volume and small range, or big volume and long wicks or tails, etc.
Price Channels - support and resistance. Price often turns at the upper, middle and lower channels in each time frame. Similar information to Fast Stoch, but with prices. Helps in planning trades.
MAs - support and resistance and trend. Mid channels and MAs are often close, but sometimes, one is better than the other in gauging reversals. MAs are also a good reminder of the trend. If you are trading below a falling MA, require extra evidence before making long trades.
Candle format and volume - effective volume. A Wyckoff type idea. If you get big volume in an up leg, you should get extra range and a close at a new trend high. If not, there are sellers present in strength. Maybe you want to lighten up if you have a position.
GT200, GT50, GT29 - yet another form of RS. This is a Decision Point indicator for the number of stocks trading above their 200, 50, 20 MA, etc. If your stock's MAs are not improving while the market MAs are, you might be in the wrong stock. Also, crossing the red and green lines can signal a reversal imminent. There are "GT" indicators for each sector as well as SPX.
Note that some of these indicators are redundant. I swap them in and out as time goes by, depending on how helpful they seem to be.
These choices are basically my interpretation of Wyckoff's principles as I understand them - for great trades, you need to know where accumulation and distribution are happening, and which stocks are leading and lagging the pack. Accumulation generally happens when the stock is weak, but eventually results in improving RS, so you would buy a dip (like a 10 or 21 day low) after these things have happened, if local price and volume action confirm a turn. Distribution generally happens when the stock is strong but leads to declining RS. So you would sell a 10 or 21 day high, again if local price and volume patterns confirm.
So, to set up your own charts, you need to form an idea of what makes prices move.
Hope that wasn't too much in one post. Have fun!
[group is sp500]
rank by ROC(21)
This would give you the SP500 listed in order of best rate of change over one month. You can vary the ROC parameter. 63 is one quarter, 251 is one year.
I appreciate your personal energy. Hopefully giving energy for something worthwhile is a way to indirectly have our gift returned.
Maybe you can confirm this for me. I am following a couple of the chart recommendations of bloggers, for example Arthur Hill's commentary. The tendency I detect is that a 52 week high is a suggestion to jump in for a continuing high, whereas my eyes see the chart and I'm expecting it to be a great short as soon as the price comes down by a tight percentage.
I seem to be a contrarian to the general take.
What I do appreciate is the emphasis on multiple time frames. It took me some years to grasp the importance of integrating multiple time frames into my brain. It may be counter intuitive, but once you get the knack it is very powerfu.
Thanks,
Hayden
My own feeling is that a 52 week high by itself doesn't tell you anything, or rather, it doesn't tell you enough by itself. You need to consider the price and volume action that leads up to that high (or any high - it could be the one month, the quarterly or the 52 week high). If prior to the break out it doesn't show strong selling, and then it punches through recent highs on big volume, and then retraces not very far on not very much volume, then it's probably going to go higher.
If it just barely crawls to a new high, or if there is not much volume leading up to the high, or if there are some tall red candles with tall volume bars preceding or following the high, then I would be much more careful about going long.
But I would wait to go short until the best (tall) up volume bars approaching the high are broken to the downside on strong volume, and then buyers fail to respond in strength. Let the buyers show they are really done, and not just maybe waiting for news, and let the sellers prove they want to take the initiative before you commit to follow them in.
A 52 week high does draw attention, because the list gets published everywhere and often there are press stories. But this can be a double edged sword. If no one is selling the stock, then the publicity attracts volume that helps move the price up. But if someone wants to get rid of their stock at a good price, they need buyers, so a new high is also a good chance to dump stock into the (possibly) late demand.
Be careful of Information Overload. You want simplistic charts as possible.
The following will show you where you have drawn the little red circles on the QQQ chart.
//Scan 11A - CCI Bullish (crossing above -100)
[type = stock] AND [country = US]
//and [SCTR > 90]
and [Daily EMA(5,Daily Volume) > 500000] AND [Daily EMA(20,Daily Close) > 10] AND [Daily CCI(14) crosses -100]
- - - - - -
Scan 12A - CCI Bearish (crossing below +100)
[type = stock] AND [country = US]
//and [SCTR > 90]
and [Daily EMA(5,Daily Volume) > 500000] AND [Daily EMA(20,Daily Close) > 10] AND [Daily CCI(14) crosses -100]
- - - - - - - - -
//Scan 11 - CCI Bullish (crossing above 0)
[type = stock] AND [country = US] AND [Daily EMA(5,Daily Volume) > 500000]
//and [SCTR > 90]
and [Daily EMA(20,Daily Close) > 10] AND [Daily CCI(14) crosses 0]
- - - - - - - -
remove the "//" from the second line which will find a shorter list.
- - - - - - - -
//Scan 12 - CCI Bearish (crossing below 0)
[type = stock] AND [country = US] AND [Daily EMA(20,Daily Volume) > 500000]
//and [SCTR > 90]
and [Daily EMA(20,Daily Close) > 10] AND [0 crosses Daily CCI(14)]
http://www.onlinetradingconcepts.com/TechnicalAnalysis/CommodityChannelIndex.html
- - - - - - - - -
http://stockcharts.com/h-sc/ui?s=FMB&p=D&yr=0&mn=6&dy=0&id=p11119724852 first circle Sept 17, Next circle Mar 9th.
http://stockcharts.com/h-sc/ui?s=AGG&p=D&yr=0&mn=4&dy=0&id=p99845148444
http://stockcharts.com/h-sc/ui?s=QQQ&p=D&yr=0&mn=4&dy=0&id=p43156857604
http://stockcharts.com/h-sc/ui?s=HA&p=D&yr=0&mn=8&dy=0&id=p51670476542
Just a thought,
Quill -
I would just add these comments for other readers:
For a very thorough discussion of the strengths and weaknesses of CCI, see the Chart School article:
https://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:commodity_channel_index_cci
Like many indicators, it works well when a trend is in place, and not so well when the trend is changing. RS and net volume indicators like OBV, AD, and Force are good for forecasting trend changes (usually by showing divergences with price) and helping you decide whether to take signals from indicators like CCI, and how large a position to take, considering the odds of the trade working out (note the chart school article recommends this confirming indicator approach).
Certainly, if you can't say what an indicator is telling you, it shouldn't be on the chart. But if it earns its keep, there no reason to leave it off.
I use Linnsoft IRT with a different scan language and maybe broader features. An exponential MA of 1 in Linnsoft found the true bottoms for a quarter.
In trying to define my goal, I'd say my dream scan would tell me when a wide range of stocks have reached or are about to reach their lowest low for the quarter. The flip side of the scan would be when they are about to reach their highest high for the quarter.
If the scan fed back numerous candidates where the low was reached a week or a month ago, that would be OK. It's to nail the scan that provides the quarterly low that is of greatest value.
My eyes see those highest highs and lowest lows across time frames, a matter of habit. But now to fine tune the scan language to catch them in the net, that's the goal.
My trading system consists of entering a long trade when the latest price is a small percentage above the lowest low. I put great faith that these highs and lows form close to a reliable indicator.
They don't necessarily make dream trades. Nimbleness is a given. But time after time those quarterly extremes get a nice bounce, up or down.
All your commentary and details are appreciated. I appreciate the sense of community and the very civil language. The comments are being examined and explored.
I may be quiet over the weekend. I've got my reading, comprehending and testing to do. Your contributions are appreciated.
Another detail that dawned on me is the way just looking at any chart, without a scan, and seeing how different indicators and time frames affects the chart can provide a wonderful synchronizing with the scan.
Linking indicator criteria and the goodie bag of overlays to scans gives a beginner like me a big hand in integrating the relationships.
Regards,
Hayden
Maybe this is a perfect time to find an indicator that catches the reversal first on an intraday chart of 60 minutes.
I'm also proposing that in this search for spotting the best indicator for quarterly highs and lows we use only the $SPX for reference.
(So much for my vow of silence).
Thanks for the Fast Stochastics reference. It is excellent. I also used a 3 exponentialMA, an 8MA and a 13MA for a tight shift in trends.
This monthly chart also shows a decline from the highest highs in 2015. Based on my interpretation of this chart, let the bulls have their fun at the moment, they will not get close to 2132. If there is a breakout to the 2100 area I may have to warm up my Humble Pie.
The logic is to relate the longest time frame to intermediate and short term, starting with the longest.
Hayden
"Maybe this is a perfect time to find an indicator that catches the reversal first on an intraday chart of 60 minutes."
Two comments.
First, it sounds like you are trying to find the exact top. Logically, there must be a highest price, but I would say your chances of recognizing it at the time it occurs are slim.
The market has many different price behaviors at both tops and bottoms. It will often display two or three or four of them before the actual top or bottom occurs. Remember, the pros know all the indicators, and they know which signals will bring people in. They trade against those people, for dimes or dollars, for as long as possible. They make it very hard to hold your position by running prices against you until your stop is hit or you bail out thinking you must be wrong.
Someone once said, in effect, the market's purpose is to take as much money as possible from as many people as possible, and that's what the pros set out to do. And they are very good at it.
So, I think it's better to wait until the games are over before taking a position. If you want to go long, put an alert ABOVE the market, wait for a price break out above resistance, then buy the retracement back near resistance. If you want to short, put your alert UNDER the market, wait for the breakdown, then short on the recovery back near broken support. You don't get the first dollar or the last, but you are more likely to get the dollars in between at lower risk.
Alternatively, you can get really aggressive (i.e. try to catch the first dollar) and guess where the shakeout level is going to be under the market for a long, or above the market for a short, so when the pros run the stops, your order will be sitting there with priority because it's probably the oldest. But, if you're wrong, and the market keeps going, you have to act quickly to get out.
Second, indicators are once removed, sometimes two or three times removed, from actual prices - meaning, they tend to trail the action, so if you are trying to catch the first dollar, they tend to be late. If you want to maximize timely entries, you need to be able to read price and volume to gauge when buyers and sellers have gained or lost the initiative.
In brief:
Prices tend to continue in one direction, until they don't. These are some signs whether they will or won't:
big volume, wide range, long body, new leg price - maximum strength, if at beginning of new leg, or crossing support/resistance, more prices due, if later in leg, possible climax, reversal or range possible;
big volume and no new leg price, or narrow range, or small body/big wick or tail - strength met by strength, trend change more likely;
Big volume bar highs and lows tend to become support or resistance for later moves.
small volume, wide range, long body - other side exhausted or holding back, normal after a climax bar in opposite direction; trend doubtful if new price; price can continue, but this bar won't offer support or resistance on the way back.
small volume, narrow range, or wicks and tails - thin market, if new leg price, trend is weak, otherwise neutral.
If the counter trend breaks the counter trend side of high volume bar (e.g., in an up leg, sellers close prices below the low of a high volume up bar), the trend must respond strongly within one or two bars, or the trend is very doubtful. If you are aggressive, consider going against the trend on a new trend price.
If the counter trend can turn prices back (down in an uptrend, up in a down trend), but cannot stir up much volume, the trend is probably OK.
Usually, price and volume will show several signs of trend weakness before the trend actually changes. The trend normally will not change until the counter trend shows strength. If the trend does not respond to counter trend strength, the new trend is most likely to prevail.
"This weekend I tried to create a scan that would analyze only the $SPX and was stumped. Is there a way to do that?"
You can add this line to your scan:
[symbol is "$SPX"]
Then add whatever indicator tests you have. If the indicator conditions are true for the date you run the scan, the scan engine will return $SPX. If it is false, it will return nothing.
Thanks for resolving my latest block.
Reminds me of an old saying. Curiosity killed the cat. Satisfaction brought him back.
Very impressive read. You know your stuff. Were you or are you working professionally? It sounds like it. I appreciate the time it takes you to explain these things. I have been watching and sometimes trading these extreme highs and lows and have little faith in the time frames under 60 minutes, but have hope for following the monthly bars.
I have been squeezed a few times too often when things are looking ripe and ready on a 15 minute chart only to get hit a short time later.
I like the fact that every bar is actually a message box for those who take the time to read.
I run simulated trades on SPX because it defines the market (and trade SPY or ETFs that correspond)
My aggressive short for March is 2024.45, from yesterday.
The 3EMA is at 1989.87 where I would start a short on the monthly bar.
Comments welcome
Hayden