Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

tendency to stay over EMA? Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
0002ct
Posted : Tuesday, March 21, 2017 3:16:25 PM
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.

Bruce_L
Posted : Tuesday, March 21, 2017 3:31:33 PM


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
0002ct
Posted : Tuesday, March 21, 2017 3:38:57 PM
Registered User
Joined: 11/19/2015
Posts: 459

This is neat. When adding this as a column, the value is the count?

Bruce_L
Posted : Tuesday, March 21, 2017 3:39:24 PM


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
0002ct
Posted : Tuesday, March 21, 2017 3:39:56 PM
Registered User
Joined: 11/19/2015
Posts: 459

Thanks very much for the awesome help, Bruce. Much appreciated. Have a good day.

0002ct
Posted : Wednesday, March 22, 2017 11:34:46 AM
Registered User
Joined: 11/19/2015
Posts: 459

Hi, Bruce. Thanks for yesterday's help. 

A few brief follow up questions:

  1. What's the longest time available for the evaluation period (below example is using 200 days)?
  2. Is it possible to do something similar for intraday? I don't need how yet, just a yes/no.
  3. 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.

Bruce_L
Posted : Wednesday, March 22, 2017 11:39:52 AM


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
0002ct
Posted : Wednesday, March 22, 2017 11:58:48 AM
Registered User
Joined: 11/19/2015
Posts: 459

Thank you for the clear explanation. As always, your help is appreciated.

0002ct
Posted : Wednesday, April 12, 2017 3:34:34 PM
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)

Bruce_L
Posted : Tuesday, April 18, 2017 9:32:43 AM


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
0002ct
Posted : Tuesday, April 18, 2017 10:48:55 AM
Registered User
Joined: 11/19/2015
Posts: 459

Hi, Bruce. Thanks very much for taking a look.

Bruce_L
Posted : Tuesday, April 18, 2017 10:57:04 AM


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
0002ct
Posted : Wednesday, April 19, 2017 9:01:09 AM
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.

0002ct
Posted : Wednesday, April 19, 2017 9:02:46 AM
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.

Bruce_L
Posted : Wednesday, April 19, 2017 9:09:59 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

You're welcome.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.