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 |

days since cross Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
0002ct
Posted : Wednesday, February 21, 2018 1:14:43 PM
Registered User
Joined: 11/19/2015
Posts: 459

Hello. Could I please be helped with the formula for:

count of bars since crossing above 10EMA?

Preferably including the current bar, obviously, if it's still above.

 

Thank you very much.

Bruce_L
Posted : Wednesday, February 21, 2018 1:27:06 PM


Worden Trainer

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

Maybe the following?

TrueInRow(C > XAVGC10, 100)

It returns 0 if price is at or below the moving average and 1 if the cross happened at the current bar. I would probably actually subtract 1 from this to make it 0 if the current bar was the bar of the cross and -1 if it is at or below.

TrueInRow(C > XAVGC10, 100) - 1



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
0002ct
Posted : Wednesday, February 21, 2018 2:45:18 PM
Registered User
Joined: 11/19/2015
Posts: 459

That works well, thank you, Bruce. 

I assume as before the "100" is the number of bars the formula includes in its lookback, yes? If so, please remind me the max number of bars I could use this formula on in a daily scenario.

On a related note, is there documentation somewhere that outlines the max number of bars that can be used in a formula under various intraday, daily, and longer-than-daily timeframes? 

Thank you, Bruce.

Bruce_L
Posted : Wednesday, February 21, 2018 3:00:05 PM


Worden Trainer

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

Each day starts the trading day with 500 bars of data and adds new bars throughout the trading day if applicable.

The base formula (C > XAVGC10) requires 10 bars to calculate and probably should have 50 or 60 in order for the exponential moving average to actually have enough data to be accurate.

So you could probably get away with using 450 instead 100, but it would be slow (and really, if you give it a try I think you will see it is probably unnecessary).

Each formula needs to be evaluated on its own. There isn't some sort of safe period which will always work. It just depends on how many bars are required to calculate the formula in its entirety and how many bars of data are available for the symbol.

Maximizing the number of bars is not necessarily to your advantage. The number of bars is also going to affect the calculation speed. In many cases you are best going with the smallest number of bars which will meet your needs instead of trying to go with the largest number of bars which could be theoretically calculated.

If you enter the formula as a new PCF and run a test, you can get the calculation speed (such as Fast, Medium, Slow, or Very Slow). You don't have to actually save the PCF in order to test the speed.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
0002ct
Posted : Wednesday, February 21, 2018 3:33:50 PM
Registered User
Joined: 11/19/2015
Posts: 459

Yes, this makes sense. Thank you.

Sadly, one last question on this topic. I think I know the answer, but there isn't a way to count the number of daily bars since a cross of the 10-month average, correct?

Bruce_L
Posted : Wednesday, February 21, 2018 3:37:41 PM


Worden Trainer

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

No, there is not. You could get the number of months, but not the number of days.

You might be able to approximate this by multiplying the period by 21 (so a 210 day exponential moving average), but it isn't actually going to match the 10 month value.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
0002ct
Posted : Wednesday, February 21, 2018 4:15:38 PM
Registered User
Joined: 11/19/2015
Posts: 459

That is exactly what I thought -- just using some kind of heuristic to approximate it, like a typical factor. I think that might be acceptable to do and then to check against a chart visually. At least for now.

Thank you very much for all of the help. Much appreciated.

Bruce_L
Posted : Wednesday, February 21, 2018 4:16:34 PM


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.