Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 11/19/2015 Posts: 459
|
Hello --
What's a way to scan for a stock's tendency to oscillate above and below over the 8EMA for a minimum number of sequential days and over a given evaluation period?
I want to scan for this:
Over the past 200 days
stock must cross above the 8EMA
and then stay above the 8 EMA for a minimum of 3 days in row
but not longer than 10 days in a row
And ideally, I would like to rank the qualifying stocks by a count of the times the above condition was true over the 200 days.
What I'm aiming for is to target a basket of stocks with a more frequent tendency to stay on one side of a moving average over a period.
Is this possible?
Thank you.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Please try the following Indicator Formula in TC2000 v17.
CountTrue(XDOWN(C, XAVGC8) AND SinceTrue(XUP(C, XAVGC8), 10) >= 3, 200)
It is based on closing prices.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 11/19/2015 Posts: 459
|
This is neat. When adding this as a column, the value is the count?
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Yes, the value is the count of the number of times the closing price crossed up through its own 8 period exponential moving average and stayed above for exactly 3 to 10 bars before crossing back down.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 11/19/2015 Posts: 459
|
Thanks very much for the awesome help, Bruce. Much appreciated. Have a good day.
|
|
Registered User Joined: 11/19/2015 Posts: 459
|
Hi, Bruce. Thanks for yesterday's help.
A few brief follow up questions:
-
What's the longest time available for the evaluation period (below example is using 200 days)?
-
Is it possible to do something similar for intraday? I don't need how yet, just a yes/no.
-
The example you provided counts oscillations to either side of the EMA (which is what I wanted). To do just one side, say counting "crosses above 8EMA" only, would the formula look bethe following?
CountTrue(XUP(C, XAVGC8) AND SinceTrue(XUP(C, XAVGC8), 10) >= 3, 200)
Thanks very much.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
There are generally 500 bars of data available, so you need to make sure all of the calculations can happen within those 500 bars.
For a daily formula this would mean the limit would be 482 bars during the trading day and 481 bars before the market opens. That said, the formula switches from being Slow at 477 bars to being Very Slow at 478 bars.
You should be able to use the exact same formula intraday.
The example actually only counts the oscillations above the EMA. It uses the crossdown in the other direction to determine if the price stayed above the EMA between 3 and 10 bars. It doesn't count the crossup until it has crossed back down in order to make sure the count is correct and to make sure the crossup only gets counted once.
A "tendency to stay below" forumla would be the following.
CountTrue(XUP(C, XAVGC8) AND SinceTrue(XDOWN(C, XAVGC8), 10) >= 3, 200)
And if you wanted to count both, you would add these together.
CountTrue(XUP(C, XAVGC8) AND SinceTrue(XDOWN(C, XAVGC8), 10) >= 3, 200) + CountTrue(XDOWN(C, XAVGC8) AND SinceTrue(XUP(C, XAVGC8), 10) >= 3, 200)
This longer combined formula switches from being Slow at 263 bars to being Very Slow at 264 bars.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 11/19/2015 Posts: 459
|
Thank you for the clear explanation. As always, your help is appreciated.
|
|
Registered User Joined: 11/19/2015 Posts: 459
|
Hi, Bruce. Is there a way to write this so it also includes a minimum average gap above the EMA for the period? Say I want to differentiate stocks that tend to cross above and then hold some minimum average gap for that "above" time.
CountTrue(XUP(C, XAVGC8) AND SinceTrue(XUP(C, XAVGC8), 10) >= 3, 200)
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I can't think of a way to do this which would be short and fast enough to be practical or post in the forums in the current implementation of the Personal Criteria Formula Language.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 11/19/2015 Posts: 459
|
Hi, Bruce. Thanks very much for taking a look.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I have been thinking about it, but the best things that are even somewhat reasonable only kind of apply. For example, we could check for how far price is above the moving average when it is above... but it wouldn't be restricted to stuff that was above for at least 3 bars.
SUM(IIF(C > XAVGC8, C - XAVGC8, 0), 200) / CountTrue(C > XAVGC8, 200)
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 11/19/2015 Posts: 459
|
Hi, Bruce. Thank you very much for following up with some additional ideas. I had a similar idea yesterday that was a klugy version of your formula above (which works well for what I'm after). I had simply replaced the close with the low which gave a kind of coarse margin over the MA.
Thanks again. Very much appreciated.
|
|
Registered User Joined: 11/19/2015 Posts: 459
|
"which works well for what I'm after" meaning your formula, not my swapping in low for close.
Thanks again.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |