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.
Hi everybody,
I am new here and would need a little help.
I would build new scan for these conditions:
-30 SMA rising (uptrend)
-Stochastic Line goes below 20 and makes "cross up" STO Signal line
-MACD Line crosses up MACD Signal
Anybody can help me with this?
0
Comments
All 3 you have listed are in the TECHNICAL INDICATORS dropdown. You would select and then click Add to have the indicator appear in the workbench. You can edit the fields to meet your needs.
SMA defaults into the workbench like this:
and [SMA(50,volume) > 9999999]
This is asking that the SMA50 for Volume be greater than 9999999.
I assume you are looking for the SMA of some price to be rising. So you would change the 50 to a 30 and change the volume to be your price choice. The Price options are Open, High, Low, Close.
So now that lines looks like this:
and [SMA(30,close) > 9999999]
You want the SMA30 to be rising so you would replace the 9999999 with the value of the SM30 X number of periods ago. Example: 1 days ago SMA(30,close)
This would filter out any securities in your Universe that the current SMA30 is less than or equal to the SMA30 yesterday.
and [SMA(30,close) > 1 days ago SMA(30,close)]
You would do similar additions for the Stochastic and the MACD. With the Stochastic you would need to choose the Fast, Full, or Slow Stochastic. The %K in the Stochastic is often called the Stochastic and the %D is called the signal. You are looking for the K to be less than 20 and the K crosses the D. Select them from the TECHNICAL INDICATORS dropdown.
The Fast Stochastic K and D default into the workbench like this:
and [Fast Stoch %K(14,3) > 80.0]
and [Fast Stoch %D(14,3) > 80.0]
You want the %K to be less than 20 so your would change that line to be < 20
and [Fast Stoch %K(14,3) < 20.0]
and then you want the %K to be crossing above the %D signal line. The < and > is replaced by the x for crossing. The cross is always going to be the element on the left is crossing above the element on the right.
and [Fast Stoch %K(14,3) x Fast Stoch %D(14,3)]
If you wanted the Stochastic to be crossing below 20 you would use
and [20 x Fast Stoch %K(14,3)] for example. The 20 level crosses above the %K, therefor the %K has crossed below.
You can change the 14,3 to be whatever you'd like.
You would follow the same logic with the MACD. Select the MACD from the TECHNICAL INDICATORS dropdown.
It gives you three options with the MACD. Line, Signal, and Histogram.
Add the ones your want, into the workbench and edit the numbers to meet your needs.
If you get stuck, copy and paste what you have from the workbench here for assistance in trouble shooting.
In my experience, while it can be helpful to time a trade with more than one indicator, two or more indicators often don't make crossovers on the same bar.
So it can be helpful to compare indicator states (below vs. above) across a range of bars. That way you don't have to specify exactly the cross over bar.
The trick is to choose the number of bars in the look back range. If you look back too far, the trade may be over before the scan picks it up. If you don't look back far enough, the scan never sees it. Maybe the number is three, maybe five, maybe it can be seven or ten.
You also have to consider the length of the MA versus the indicator parameters. A move sharp enough or long enough to get Fast K below 20 may also turn down the MA if the MA is too short or the indicator parameters are too long. So play with the parameters once you get the scan working.
Let's say the right range is five bars. You could start with
[group is sp500] // or your choice.
and [sma(30, close) > 5 days ago sma(30, close)] // maybe this could have its own range, so maybe 10 or 15 days ago
and [min(5, Fast %K(14,3)) < 20] // FastK below 20 on at least one of the last 5 bars
// Fast K crossover in the last few bars - was below, now above
and [5 days ago Fast %K(14,3) < 5 days ago Fast %D(14,3)] // Fast K below FastD 5 (exactly) bars ago
and [Fast %K(14,3) > Fast %D(14,3)] // FastK above FastD today
// MACD crossover in the last few bars
and [5 days ago MACD Line(12,26,9) < 5 days ago MACD Signal(12,26,9)]
and [MACD Line(12,26,9) > MACD Signal(12,26,9)]
sma 30 and macd lines are good, but all 3 lines for stoch are not good. I don't know how to fix it. Can you please check it and try to fix it.
Thanks!
Fast %K and %D should be
Fast Stoch %K(14,3)
Fast Stoch %D(14,3)
Lesson - when writing scans, always select indicators from the Technical Indicators drop down below the scan window to get the correct syntax (as @lmkwin pointed out). So if you get an error from the advanced editor (and always have the advanced editor on - check mark in the upper right corner), start there.
Another way to identify whether a trend might be in place is to test the upper and lower channel for its direction.
For instance, to see if there is a 30 day up trend in place or starting, you could write
and [ // begin or statement
[Upper Price Chan(30) > 31 days ago Upper Price Chan(30)] // trend probably in place
or
[Lower Price Chan(30) > 31 days ago Lower Price Chan(30)] // trend has probably stopped falling, may be a reversal
] // end or statement
After 30 days, the 30 day channels have to tick up or down. If the trend is up, the upper channel will usually do so (much) sooner, while the lower channel will wait until day 31. Vice versa for a down trend.
Of course the stock could be in a range, but that can be true of an MA test also. The channel test is a little more reliable because the MA tends to fluctuate more, especially in a range.
Thank you for correction. I will play with it now for some time.
I have one more question.
This is Bullish scan.
What do I have to change to make it Bearish scan?
40 SMA DOWNTREND, STOCH. ABOVE 80 THEN CROSSDOWN (K CROSS D), AND MACD CROSS MACD SIGNAL
[TYPE = STOCK]
AND [COUNTRY = US]
AND [group is sp500] //
AND [CLOSE > 10]
AND [SCTR > 75]
and [sma(40, close) > 5 days ago sma(40, close)] //
and [min(5, Slow Stoch %K(14,3)) < 20] //
and [5 days ago Slow Stoch %K(14,3) < 5 days ago Slow Stoch %D(14,3)] //
and [Slow Stoch %K(14,3) > Slow Stoch %D(14,3)] //
and [5 days ago MACD Line(12,26,9) < 5 days ago MACD Signal(12,26,9)]
and [MACD Line(12,26,9) > MACD Signal(12,26,9)]
and [sma(40, close) < 5 days ago sma(40, close)] // sma 40 falling
and [max(5, Slow Stoch %K(14,3)) > 80] // price has been at the top of its range
and [5 days ago Slow Stoch %K(14,3) > 5 days ago Slow Stoch %D(14,3)] // K was above D
and [Slow Stoch %K(14,3) < Slow Stoch %D(14,3)] // now K is below D
and [5 days ago MACD Line(12,26,9) > 5 days ago MACD Signal(12,26,9)] // Line was above signal
and [MACD Line(12,26,9) < MACD Signal(12,26,9)] // now Line is below signal
I'm not sure whether SCTR > 75 is a good idea. Maybe SCTR < 75, maybe <50. You just have to experiment.
I don't know if you can scan for past SCTR values, If you can, you want SCTR declining.
I don't know if this is "legal":
and [ 20 days ago SCTR > 80]
and [SCTR < 70]
If it is legal, I don't know what the right look back period is - 20 days (as shown), 30, 60?
Also, I don't know if Slow Stoch works better that Fast Stoch. Slow Stoch is Fast Stoch smoothed out - its less volatile. Sometimes that helps, sometimes it doesn't.
Once again markd, thank you!
This is all new to me, and I have a lot to learn.