Registered User Joined: 3/20/2011 Posts: 25
|
I want to be alerted when a symbol's Stochastic has hit a low value during the past week(p=5).
How do I write a pcf for how many times a stock's Stochastics value has hit a 3-period minimum over the last p days?
For example,
Does CountTrue(Stoc5.2=Min(Stoc5.2),3),5) tell me how many times the stock has hit its lowest Stoc5.2 value during a 3-bar period at anytime during the past 5 days on a daily chart?
Any help would be much appreciated. Or give me a link to help on your site(s) for finding the minimum or maximum of a condition as a watchlist column condition pcf.
Thanks,
John
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
It depends on what you mean by hit a 3-period minimum. If the 3-period minimum is the minimum at the time, then the basic concept behind your formula should work.
CountTrue(STOC5.2 = MIN(STOC5.2, 3), 5)
But if you mean the previous stochastics hit the current minimum (instead of the minimum at the time), then you would need to write a longer formula (the more I think about it, the more I don't think you would actually be trying to do this but it still illustrates a point about PCFs and how CountTrue() works).
IIF(STOC5.2 = MIN(STOC5.2, 3), 1, 0) + IIF(STOC5.2.1 = MIN(STOC5.2, 3), 1, 0) + IIF(STOC5.2.2 = MIN(STOC5.2, 3), 1, 0) + IIF(STOC5.2.3 = MIN(STOC5.2, 3), 1, 0) + IIF(STOC5.2.4 = MIN(STOC5.2, 3), 1, 0)
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 3/20/2011 Posts: 25
|
Thanks for your prompt reply, Bruce.
Your formula counts the number of days Stoc5.2 hits today's 3-bar min. What about the 3-bar minimum four days ago?
Isn't that what CountTrue is supposed to do? I'm looking for a way to repeat this test every day for the past 5 days. Effectively, I should get a CountTrue result of 5 if this test {(today's Stoc5.2=min(Stoc5.2,3)} is true every day over the past 5 days. Am I correct in assuming this new function will return the stock whose Stoc5.2 value is at the minimum value each day for the full period of 5 days?
Maybe the TrueInRow function will handle this test more efficiently?
Or, should I use CountTrue with a period of 5 in the minimum function as well as the CountTrue function? That way the revised CountTrue function will return a number representing how long the Stock Stoc5.2 remained at its 5-day low.
I love how Worden is continually improving the strength of their charting software!
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
The second formula given in my response is probably not what you want. It is just there to illustrate the limitations of the first formula. It compares all five bars to the current three bar minimum.
What you want is pretty much the formula you already had. The only change I made was to eliminate the extra closing parenthesis in your formula which would cause an error message. This formula compares the stochastic of four bars ago to the three bar minimum of four bars ago (which makes more sense than the other way).
If you do in fact want it to be true all 5 days, then TrueInRow() is going to theoretically be more efficient than CountTrue() because TrueInRow() can abort on the first false bar while CountTrue() needs to check all of the bars in order to get an accurate count.
TrueInRow(STOC5.2 = MIN(STOC5.2, 3), 5) = 5
The same is even more true if you are in fact interested in the number of bars in a row, as CountTrue() does not return this value.
TrueInRow(STOC5.2 = MIN(STOC5.2, 3), 5)
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 3/20/2011 Posts: 25
|
Thanks Bruce. Very helpful.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|