Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
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.
|
|
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
|
|
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.
|
|
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
|
|
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?
|
|
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
|
|
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.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |