Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 10/9/2011 Posts: 485
|
Good afternoon. I was wondering if there is a way to count how many times a signal triggered in the last say 100 bars.
Lets take a simple example. If I want to count the number of green bars in the last 100 bars? Or number of OB bars in the last 100 bars? Number of inside bars in the last 100 bars.
is it possible to write a pCF to do this counting?
Thank you for your help.
|
|
Registered User Joined: 9/17/2010 Posts: 484
|
I'm not the expert but you may find some help over the week end in this post.
Is it possible to write a pcf that will output bars up? |
|
|
Administration
Joined: 9/30/2004 Posts: 9,187
|
You can plot a Custom PCF % True that will plot the percentage of bars that a formula is True over the previous x bars. So if you have a formula for "green bars" and "OB bars", you can pop that into a Custom PCF %True indicator.
Since your lookback is 100 bars, the % value will match the count. 41% means it passed 41 of the last 100 bars.
|
|
Registered User Joined: 10/9/2011 Posts: 485
|
Thank you for the response. Appreciate it.
Would you be able to provide an example of how to set this up. Say my formula is
h > h1 and l < l1
I want to find out how many such conditions were present in the last X bars. If 100 is the max tc2000 allows, then lets say last 100 bars.
How would I set that up? Is there a CountIf function? Many platforms have something like
CountIf(Condition, Numberofbars) where it tells me how many times a condition occurred in the bars specified. Would like to replicat ethe same in tc2000.
Thank you for your help.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Add a Custom PCF Indicator to the chart.
Edit the Custom PCF Indicator to set the Period to the number of bars of interest and the Average Type to Simple.
If the Period is 100 and the Condition Formula of interest is H > H1 AND L < L1 then you would use the following Indicator Formula.
100 * ABS(H > H1 AND L < L1)
So you would be putting the Condition Formula of interest inside an ABS() function and multiplying it by the Period.
The above method would give you a count for any Period. So you could set the Period to 50 and use 50 * ABS(H > H1 AND L < L1) to display the count using the Custom PCF Indicator.
StockGuy was mentioning the special case where the period is 100. In this case, you can use a Cusotm PCF % True Indicator instead of using a Custom PCF Indicator. You would set the Period to 100 and the Average Type to Simple as before, but you can just use the formula of instead instead of putting it inside an ABS() function and multiplying it by the Period. So the Boolean Formula would just be the following.
H > H1 AND L < L1
Note that the Custom PCF % True Indicator only gives you a count when the Period is 100. This is because the count and the percentage of the time something is true is the same in such instances. In other cases it ould still return the percentage of the time something is true, it just wouldn't be the count of how many times it was true.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 10/9/2011 Posts: 485
|
Beautiful. I tried this out. Worked out well. Thank you Bruce for your detailed response appreciate it.
Can the same method be used to get the avg bar size? Say I do 100 * (h-l) and set the avg to 100 as well. The value I get is the total of h-l in the last 100 bars and I divide that by 100 to get the avg h-l in the last 100 bars. is that a good way to do this?
Thank you again bruce,
Have a good day
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
That should work just fine.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |