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.
Consecutive true days - SMA, EMA, etc -
Comments
-
I don't know how to do it for SMAs, but for EMAs you can try this (I'm hoping I remember this right):
[group is sp500]
and [min(20, MACD Hist(1,30,0)) > 0]
For MACD Hist, the first parameter is the shorter EMA and the second parameter is longer EMA. The "1" for the first parameter above represents the close (EMA of length 1 is the same as the close). The third parameter is the Signal line - which is an EMA of the difference between the first two EMAs. But we don't want that - we just want the difference between the first two EMAs - so the third parameter is "0".
We want to min(... ) > 0 because a value less than zero would indicate the close went below the EMA, and that would interrupt the count of consecutive closes above the EMA.
For the second part, if EMAs are OK, this seems to work:
[group is sp500]
and [min(30, MACD Hist(20,50,0)) > 0]
and [min(30, MACD Hist(50,200,0) > 0]
Same explanation applies, just the parameters are different.
Make sure you check the results with a chart style showing the EMAs on the chart and MACD Hist(s) below with the corresponding parameters.
P.S. - I learned this trick years ago on this site from another user - it's an "off label" use for an indicator that you wouldn't come up with on your own without a lot of experience - and creativity.0 -
Great tip @markd .
"Old school" would have been a lengthy nested statement like
close > 30 day ema
and 1 day ago close > 1 day ago 30 day ema
and 2 day ago close > 2 day ago 30 day ema
and 3 day ago close > 3 day ago 30 day ema
and 4 day ago close > 4 day ago 30 day ema
and 5 day ago close > 5 day ago 30 day ema
etc..
0 -
You need to add a second ) before the >
[group is sp500]
and [min(30, MACD Hist(20,50,0)) > 0]
and [min(30, MACD Hist(50,200,0)) > 0]0 -
Think of the ( and the [ as being part of a team. There must be a corresponding ) and ] for every ( or [.
Parsing is usually a ( ) issue but also can just be that the system can't do what you are asking.
[ ] issues usually result with an error message about mis-matched brackets.0 -
lmkwin is right on the money - you should always have an even number of parentheses (and brackets).
I should have added a warning about watching parentheses when using nested functions.0 -
Great, I didn't catch the missing item. Thanks all!0
Categories
- All Categories
- 2.3K StockCharts
- 395 SharpCharts
- 146 Other Charting Tools
- 69 Saved Charts and ChartLists
- 1.5K Scanning
- 73 Data Issues
- 177 Other StockCharts Questions
- 218 Technical Analysis
- 155 Using Technical Analysis
- 2 InterMarket and International
- 19 Market and Breadth Indicators
- 42 Market Analysis
- 109 Trading
- 109 Trading Strategies
- 163 S.C.A.N the StockCharts Answer Network forum
- 65 Using this StockCharts Answer Network forum
- 98 s.c.a.n. archives
- 5 Off-Topic
- 6 The Cogitation & Rumination Emporium
- Forum Test Area