Registered User Joined: 10/21/2004 Posts: 5
|
Does TC2000 have something similar to ATR as described in (removed by Moderator)
If not, could you help us with PCFs and indicator for ATR . Thanks
|
|
Registered User Joined: 11/18/2004 Posts: 6
|
I would be VERY interested in this. thanks JJL
|
|
Worden Trainer
Joined: 10/1/2004 Posts: 4,308
|
Let me do some poking around about Average True Range (starting with the link you provided), and I'll get back to you.
- Doug Teaching Online!
|
|
Worden Trainer
Joined: 10/1/2004 Posts: 4,308
|
For starters, ATR requires that, for each day, you look at three different ranges, and the true range is the largest of the three. This would require the use of IF/THEN statements, and our PCF language currently does not include that capability.
I'm still going to continue poking around on this one to see if there is another way to accomplish creating ATR in the program. If I find something, I'll post it here. If not, I'll put a post here indicating I've come up dry. I'm just not willing to give up on this one just yet...even though it looks like the answer is no.
- Doug Teaching Online!
|
|
Registered User Joined: 11/18/2004 Posts: 6
|
As I have looked at different posts it seems like a number of requests need the use of IF/THEN functionality. Given that information are they plans to incorporate IF/THEN in?
Thanks JJL
|
|
Worden Trainer
Joined: 10/1/2004 Posts: 4,308
|
I don't know the answer to that. I do know that the suggestion has been submitted to the development staff for review and consideration.
- Doug Teaching Online!
|
|
Registered User Joined: 10/7/2004 Posts: 264
|
I didn't come up with this, I think credit goes to user Tanstaafl. Try this formula for ATR. It is a 10 day ATR. You can expand and contract as you like. I calculated it by hand a while ago, you may want to just to confirm its accuracy. Would be a lot simpler with IF/THEN capability. Good luck.
(AVGH10 - AVGL10 + (ABS(H - C1) + ABS(L - C1) + ABS(H1 - C2) + ABS(L1 - C2) + ABS(H2 - C3) + ABS(L2 - C3) + ABS(H3 - C4) + ABS(L3 - C4) + ABS(H4 - C5) + ABS(L4 - C5) + ABS(H5 - C6) + ABS(L5 - C6) + ABS(H6 - C7) + ABS(L6 - C7) + ABS(H7 - C8) + ABS(L7 - C8) + ABS(H8 - C9) + ABS(L8 - C9) + ABS(H9 - C10) + ABS(L9 - C10) ) / 10 ) / 2
|
|
Worden Trainer
Joined: 10/1/2004 Posts: 4,308
|
Golfman25:
Thanks for sharing Tanstaafl's formula for ATR. I have not tested it myself, but someone on our tech staff has, and he reports that as far as he can tell, it works.
The tech agent has also come up with another approach to try. Again, I have not tested this personally, but it uses the programs new SGN function, and the tech agent said it appears to work. I pass it along not as a definitive solution to plotting ATR, but as part of a work in progress here, thinking you and djenner and the others who have posted here may want to give it a try on your end. Here it is:
(SGN(SGN(C1-H)+1)*(C1-L))+(SGN(SGN(L-C1)+1)*(H-C1))+((SGN(SGN(H-C1)-1)+1)*(SGN(SGN(C1-L)-1)+1)*(H-L))
You would plot the above formula as a custom indicator, and set the smoothing average to whatever ATR period you wanted to use.
- Doug Teaching Online!
|
|
Registered User Joined: 10/7/2004 Posts: 799 Location: Duluth, GA
|
Please go to the Worden Archives and review the Worden Report dated June 6, 2003. Title is "ATR Two Ways". I explained the logic behind the indicator, and presented two different PCF techniques for calculating it.
Jim Dean
|
|
Registered User Joined: 10/7/2004 Posts: 799 Location: Duluth, GA
|
I just realized that the Archives are not yet integrated with this site, and there is no place to upload files (yet?). So, I've attached the text of the Worden Report about this important topic below. Sorry about the length :~)
ATR's in PCF's - Two Ways Copyright 2003, James D. Dean
There are at least three different ways to model Wilder's TR (True Range) and ATR (Average True Range) correctly in a TeleChart PCF. This article provides descriptions of the two most useful ones (they each have pro's and con's for PCF use). One of these methods utilizes the PCF trick for handling If/Then/Else statements in PCF's ... another powerful tool, in and of itself.
In comparison to Daily Range (High - Low), a bar's "True Range" encompasses what happened in the most current bar, plus what happened since the Close of the day before. That is, it includes what happened today, and the NIGHT before.
The rationale for the importance of True Range: since a single bar's H-L "daily" range does not necessarily include the impact of opening gaps, a better measure of the true "volatility" of a stock is necessary. Wilder's True Range can be succinctly expressed as: Max(H,C1)-Min(L,C1). This is NOT a valid PCF (Max and Min are conveniences here, for discussion purposes). That is, the TR is the higher of today's High and yesterday's Close, minus the lower of today's Low and yesterday's Close. This takes overnight gaps into account.
----- Algebraic PCF's for Min, Max and ATR -----
The Min(A,B) and Max(A,B) functions can be visualized as a vertical bar with two endpoints A and B The lowest (Min) value on the bar can be found by going to the halfway-point of the bar, then subtracting half the height of the bar. The halfway-point, in PCF terms, is (A+B)/2, and half of the bar's height is Abs(A-B)/2 (the use of Abs is necessary since we don't know which of A & B are larger). So, if we put that together: Min(A,B)= (A+B)/2 - Abs(A-B)/2 = (A+B-Abs(A-B))/2 Similarly, the Max is half the height plus the halfway point: Max(A,B)= (A+B)/2 + Abs(A-B)/2 = (A+B+Abs(A-B))/2
We can combine the Min and Max formulae above into a single PCF for TR: Max(H,C1)-Min(L,C1) = (H+C1+Abs(H-C1))/2 - (L+C1-Abs(L-C1))/2 This can be algebraically reduced to: Wilder's True Range = (H-L+Abs(H-C1)+Abs(L-C1))/2
When working with TR, we usually want to know its average over a period of time "N", to get a better general measure of the stock's volatility. This is simply a series of "N" TR calc's added together, divided by N. A three-day Average True Range would be: ((H-L+Abs(H-C1)+Abs(L-C1))/2+(H1-L1+Abs(H1-C2)+Abs(L1-C2))/2+(H2-L2+Abs(H2-C3)+Abs(L2-C3))/2)/3 We can algebraically rearrange this: (H+H1+H2- L-L1-L2 + Abs(H-C1)+Abs(L-C1) + Abs(H1-C2)+Abs(L1-C2) + Abs(H2-C3)+Abs(L2-C3)) / 3 / 2 The PCF language offers an "Avg" function: AvgX3 = (X+X1+X2)/3, where X can be O,H,L,C,V. That offers a convenience for further simplification: (AvgH3 - AvgL3 + ( Abs(H-C1)+Abs(L-C1) + Abs(H1-C2)+Abs(L1-C2) + Abs(H2-C3)+Abs(L2-C3)) / 3) / 2 Pulling it all together, this compact and fast-calculating form will accurately model the 3-day Average of Wilder's True Range = (AvgH3 - AvgL3 + (Abs(H-C1)+Abs(L-C1) + Abs(H1-C2)+Abs(L1-C2) + Abs(H2-C3)+Abs(L2-C3) )/3 )/2
Important Hint: to quickly generate other "N"-day versions, copy the (final) outline form of the PCF into Windows NotePad, change the Avg #'s to N, and copy+paste the Abs lines for as many days as you wish, incrementing the H,L,C #'s by one for each new line. Also change the /3 to /N. Then paste the whole thing straight into the PCF editor ... no need to kill the extra spaces or new-lines ... TC handles that automatically. Warning: don't use Tab for indentation - the PCF editor doesn't handle it ... stick to the spacebar!
Credit where credit is due: the original suggestion for this algebraic approach was offered by BusterMu in yahoo's "auxiliaryTC2000usergroup".
----- If/Then/Else PCF's for Min, Max and ATR -----
"Boolean math" provides a means of handling simple "If / Then / Else" logic within numeric-value PCF's. The method is versatile and useful for many applications. For example, the "Min(A,B)" function can be stated as: "If A<B, Then Min=A, Else Min=B".
To do this in a PCF, we combine logical True/False tests with numeric values to produce a numeric result. Here's the trick (works every time): the logical value "True" has a numeric equivalent of minus-one, and "False" is numerically equivalent to zero. For instance: "(A<B)*A" will yield a PCF result of either 0*A=0, or (-1)*A=(-A), depending on whether or not A is less than B. Similarly, "(A>=B)*B" will yield a PCF result of either 0*B=0, or (-1)*B=(-B).
If we ADD those two fragments together, and multiply the result by (-1), we get the Minimum of A & B: Min(A,B)= (-1) * ( (A<B)*A + (A>=B)*B ) Similarly, we can find the Maximum of A & B: Max(A,B)= (-1) * ( (A>B)*A + (A<=B)*B ) Note that the parentheses are required, even around the minus one.
Going back to our earlier discussion of True Range, we now can build an alternative PCF, based on Boolean-math Min & Max: True Range = Max(H,C1)-Min(L,C1) =(-1) * ( (H>C1)*H + (H<=C1)*C1 ) - (-1) * ( (L<C1)*L + (L>=C1)*C1 ) Using algebra to simplify, we can eliminate paren's and (-1) terms: TR = (L<C1)*L + (L>=C1)*C1 - (H>C1)*H - (H<=C1)*C1
Again, we need to incorporate several days of data to provide a general measure of volatility, expressed as the Average True Range ... here's the valid PCF for a 3-day ATR: ( (L<C1)*L + (L>=C1)*C1 - (H>C1)*H - (H<=C1)*C1 + (L1<C2)*L1 + (L1>=C2)*C2 - (H1>C2)*H1 - (H1<=C2)*C2 + (L2<C3)*L2 + (L2>=C3)*C3 - (H2>C3)*H2 - (H2<=C3)*C3 ) / 3 Refer to the Hint above for quick ways to construct longer averages.
----------
Recap: we've seen two different ways to write accurate PCF's for Wilders True Range and its Average. Along the way, we've also seen how to use PCF's to determine the Min and Max of two different values, and how to apply If/Then/Else logic in a PCF. Note that you can use those Min, Max and If/Then constructs with A & B *formulae*, not just with A & B as single prices. This is a very powerful PCF capability!
Once again, I applaud the "simple elegance" of the TeleChart program. It provides an incredible amount of power and flexibility, in an easy to use, clean and fast platform. Don't sell short the PCF toolkit ... instead, use some high-school algebra and creativity to make it work for you ... and never forget: there ain't no such thing as a free lunch!
|
|
Registered User Joined: 6/17/2008 Posts: 33
|
transtaafl, when you mean (you can use those min, max and if/then constructs with A&B*formulae*,not just with A&B as single prices), do you mean (-1)*((A<B)*A+(A>B)*B) (-1)*((A>B)*A+(A<B)*B)time the true range formula time the 3d ATR? PLEASE explain!thx
|
|
Guest-1 |