Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 3/13/2006 Posts: 25
|
How ca I write the following PCF:
1- Today's bar close in the uper half of the range
2 -Today's bar close in the lower half of the range
|
|
Registered User Joined: 10/9/2011 Posts: 485
|
Todays mid point is (h+l) / 2
C > (h+l)/2 is close in upper half
C < (h+l)/2 is close in lower half
To make it generic say if you want to do close @ top 30%
c > l + (h-l)*2/3
if you want to do close @ bottom 30%
c < h - (h-l)*2/3
For 10% you can replace 2/3 to 0.9
For 20% you can replace 2/3 to 0.8
For 40% you can replace 2/3 to 0.6
Hope this helps.
Good luck
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Another option would be to use the built in syntax for stochastics. So top half of range could be written as follows.
STOC1 > 50
Bottom have of range could be written as follows.
STOC1 < 50
Top 30% of range could be written as follows.
STOC1 >= 70
Bottom 30% of range could be written as follows.
STOC1 <= 70
Note that I didn't include = in the top half and bottom half formulas because you would also get 50 when the high equals the open, but we could specifically check for a non-zero range bar. In which case top half of range could be written as follows.
STOC1 >= 50 AND H > L
And bottom half of range could be written as follows.
STOC1 <= 50 AND H > L
Understanding Stochastics
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 10/9/2011 Posts: 485
|
Bruce,
That was a very good technique using stoc. Cool.
We could use that to figure out stocks in the range top or range bottom in the last X bars.
Thank you,
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
The range over multiple bars is definitely its more traditional use, but it isn't limited to multiple bar situations. It also works for a singel bar.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 10/9/2011 Posts: 485
|
Awesome. Thank you.
Is it fair to say
Stoc10 > 80 is price in the top 20% 10 bar range?
This has some cool applications by adding multiple bar ranges something like price near 50% of the 50 bar range and in the top 10% of the 10 bar range like
Stoc50 > 50 and stoc10 > 90
Thank you Bruce.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Yes, it is fair to say STOC10 > 80 means price is currently in the top 20% of its 10 bars range. This would also be the case when using STOC10 >= 80 as well. The difference is in if if you would want to count the borderline between the bottom 80% and top 20% as being part of the top 20% of the range or not.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 3/13/2006 Posts: 25
|
Thanks all. How about how to write the following:
1- One of the last five bars (including the last one) had touched the 50 period EMA (could be from below or above.
2- Stochasitic 12,3,3 at one of the last five bars (including the last one) was below 20
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
If number 1 does not include gapping up or down through the moving average as touching and you want to check if the bar touched the exponential moving average at the close of the bar.
(L <= XAVGC50 AND XAVGC50 <= H) OR (L1 <= XAVGC50.1 AND XAVGC50.1 <= H1) OR (L2 <= XAVGC50.2 AND XAVGC50.2 <= H2) OR (L3 <= XAVGC50.3 AND XAVGC50.3 <= H3) OR (L4 <= XAVGC50.4 AND XAVGC50.4 <= H4)
Including gaps from the previous bar would make the formula a bit more complicated.
((H1 < XAVGC50.1 OR L <= XAVGC50) AND (XAVGC50 <= H OR XAVGC50.1 < L1)) OR ((H2 < XAVGC50.2 OR L1 <= XAVGC50.1) AND (XAVGC50.1 <= H1 OR XAVGC50.2 < L2)) OR ((H3 < XAVGC50.3 OR L2 <= XAVGC50.2) AND (XAVGC50.2 <= H2 OR XAVGC50.3 < L3)) OR ((H4 < XAVGC50.4 OR L3 <= XAVGC50.3) AND (XAVGC50.3 <= H3 OR XAVGC50.4 < L4)) OR ((H5 < XAVGC50.5 OR L4 <= XAVGC50.4) AND (XAVGC50.4 <= H4 OR XAVGC50.5 < L5))
A Condition Formula for a simple stochastit 12,3 %K being below 20 on at least one of the most recent 5 bars could be written as follows.
MIN(STOC12.3,5) < 20
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |