Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

average true range pcf Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
koorana1
Posted : Tuesday, March 1, 2005 3:04:01 AM
Registered User
Joined: 2/14/2005
Posts: 3
(( (H - L + ABS(C1 - H) + ABS(C1 - L)) / 2 + (H1 - L1 + ABS(C2 - H1) + ABS(C2 - L1)) / 2 + (H2 - L2 + ABS(C3 - H2) + ABS(C3 - L2)) / 2 + (H3 - L3 + ABS(C4 - H3) + ABS(C4 - L3)) / 2 + (H4 - L4 + ABS(C5 - H4) + ABS(C5 - L4)) / 2 + (H5 - L5 + ABS(C6 - H5) + ABS(C6 - L5)) / 2 + (H6 - L6 + ABS(C7 - H6) + ABS(C7 - L6)) / 2 + (H7 - L7 + ABS(C8 - H7) + ABS(C8 - L7)) / 2 + (H8 - L8 + ABS(C9 - H8) + ABS(C9 - L8)) / 2 + (H9 - L9 + ABS(C10 - L9) + ABS(C10 - L9)) / 2 + (H10 - L10 + ABS(C11 - L10) + ABS(C11 - L10)) / 2 + (H11 - L11 + ABS(C12 - L11) + ABS(C12 - L11)) / 2 + (H12 - L12 + ABS(C13 - L12) + ABS(C13 - L12)) / 2 + (H13 - L13 + ABS(C14 - L13) + ABS(C14 - L13)) / 2 + (H14 - L14 + ABS(C15 - L14) + ABS(C15 - L14)) / 2 + (H15 - L15 + ABS(C16 - L15) + ABS(C16 - L15)) / 2 + (H16 - L16 + ABS(C17 - L16) + ABS(C17 - L16)) / 2 + (H17 - L17 + ABS(C18 - L17) + ABS(C18 - L17)) / 2 + (H18 - L18 + ABS(C19 - L18) + ABS(C19 - L18)) / 2 + (H19 - L19 + ABS(C20 - L19) + ABS(C20 - L19)) / 2 + (H20 - L20 + ABS(C21 - L20) + ABS(C21 - L20)) / 2 + (H21 - L21 + ABS(C22 - L21) + ABS(C22 - L21)) / 2 + (H22 - L22 + ABS(C23 - L22) + ABS(C23 - L22)) / 2 + (H23 - L23 + ABS(C24 - L23) + ABS(C24 - L23)) / 2 + (H24 - L24 + ABS(C25 - L24) + ABS(C25 - L24)) / 2 + (H25 - L25 + ABS(C26 - L25) + ABS(C26 - L25)) / 2 + (H26 - L26 + ABS(C27 - L26) + ABS(C27 - L26)) / 2 + (H27 - L27 + ABS(C28 - L27) + ABS(C28 - L27)) / 2 + (H28 - L28 + ABS(C29 - L28) + ABS(C29 - L28)) / 2 + (H29 - L29 + ABS(C30 - L29) + ABS(C30 - L29)) / 2 + (H30 - L30 + ABS(C31 - L30) + ABS(C31 - L30))2) / 31)
ryurow
Posted : Tuesday, March 1, 2005 3:20:12 PM
Registered User
Joined: 10/12/2004
Posts: 7
Nice!
Doug_H
Posted : Tuesday, March 1, 2005 3:33:27 PM


Worden Trainer

Joined: 10/1/2004
Posts: 4,308
Moderator moving this topic to the PCF and Easy Scan forum where it fits better.

Thanks, koorana1, for sharing your work!

- Doug
Teaching Online!
ajclarke88
Posted : Thursday, March 3, 2005 7:18:18 PM
Registered User
Joined: 1/5/2005
Posts: 24
This is truly a great help!

Thanks a million for sharing it...with everyone!!
dpekerow
Posted : Thursday, March 3, 2005 9:45:09 PM
Registered User
Joined: 1/28/2005
Posts: 5
whooppee! you rock dude.
j2d2
Posted : Monday, March 7, 2005 2:28:14 PM

Registered User
Joined: 1/14/2005
Posts: 21
Here is the standard definition of Average True Range:
Calculation

The True Range indicator is the greatest of the following:

The distance from today's high to today's low.

The distance from yesterday's close to today's high.

The distance from yesterday's close to today's low.

The Average True Range is a moving average (typically 14-days) of the True Ranges.

Would someone please explain how the PCF calculation presented here is anything more than an approximation of ATR? That said, I am not even certain that it is a good approximation. It appears to me that on any particular day the greater of either of three possible values depends upon being able to use only one of three possible values. To make this comparison one normally uses the "OR" combined with an "IF". I have found no way so far to incorporate or replace this type of expression in the currently available PCF syntax. Therefore any PCF which simply averages the three possibilities which would be (H-L) OR ABS(C1-H)OR ABS (L1-C)and extend the series to whatever number of days/periods is desired does not fit the standard definition for ATR. I have observed several examples of PCF's for ATR presented at www.tradeon.com that resemble what is shown here. So far, I fail to understand how any of them actually meet the standard definition of the true value of ATR. If there is a part of this puzzle that I am failing to grasp, please feel free to inform me of what it is.

My current solution to finding true ATR has been to create three custom indicators. One for each of the three possible values in the standard definition and to put all three in contrasting colors one of the lower positions of my Chart Template. Then I can use the side button of that chart segment to scan through the three plots to find the actual value of each and which is greater on any particular day. However, this solution preludes having a PCF that could be included in a Scan for various ranges of true ATR.
Craig_S
Posted : Monday, March 7, 2005 2:42:46 PM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
You might find this thread interesting:

Average True Range (ATR) & Stop Losses

- Craig
Here to Help!
Tanstaafl
Posted : Tuesday, March 8, 2005 12:49:05 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Hi, J2D2:

The thread that Craig referenced has a copy of the 6/6/03 Worden Report at its end, which explains how to implement If/Then constructs in PCF's, specifically for use in True Range calcs. It also explains how, for True Range calcs, the If/Then can be avoided using a neat trick of algebra that was originally suggested by Jim Murphy ("bustermu").

The representation of Wilder's True Range = Max(H,C1)-Min(L,C1) is PRECISELY modelled by the PCF-able equation:
(H-L+Abs(H-C1)+Abs(L-C1))/2
The development of that formula is fully explained in my article published as a Worden Report on 6/6/03. This article adds comments regarding the application of Moving Averages to the True Range formula. Most people nowadays would use a Simple Moving Average with that formula for most applications of ATR - as I did in the Worden Report.

However, it should be stated for the record that Wells Wilder's 1978 book which originally defined True Range and how to work with it (in many different ways, including RSI, ADX, Volatility, etc), did NOT use a simple moving average as its basis.

Wilder preferred a "forward weighted" moving average of his own definition ... not as reactive as an Exponential moving average, but smoother and often more useful than a Simple MA. The formula for an N-day Wilder's Smoothing is:
Today's WS(True Range) = ( Today's True Range + ( (N-1) * Yesterday's WS(TR) ) ) / N
As a result of this, unfortuately, the correct mathematical model for Wilders Smoothing is an infinite series of terms ... if you truncate that series you create a more workable formula, but also introduce error into the process.

Most of the purposes that I use ATR for are related to Risk analysis and control ... system theory calls for a Simple Moving Average in those applications. However, if you want to use True Range as an Indicator which quantifies volatility, I think that Wilder's Smoothing provides a better moving-average method.

Over the years, I've developed Excel spreadsheets to help build the PCF's required for stuff like this - a few samples of PCF's related to ATR's are provided below, to help illustrate the differences discussed above. The Wilder's smoothing and Exponential smoothing examples have been truncated to series with <0.1% error, which should be plenty accurate enough for typical trading-related systems. They are all based on Daily-bar calcs (but could be altered easily enough for weekly or whatever).

I suggest that you plot these as Custom indicators and study the differences, to see what works best for you. The somewhat odd structure of the multipliers, etc are related to the Excel generation process, and designed to optimize accuracy of internal calculations in TC.

5dayATR, Simple MA:
.2*( (H0-L0+Abs(H0-C1)+Abs(L0-C1)) +(H1-L1+Abs(H1-C2)+Abs(L1-C2)) +(H2-L2+Abs(H2-C3)+Abs(L2-C3)) +(H3-L3+Abs(H3-C4)+Abs(L3-C4)) +(H4-L4+Abs(H4-C5)+Abs(L4-C5)) ) / 2

5dayATR, Exponential MA <0.1% error:
.01*( 33.3559*(H0-L0+Abs(H0-C1)+Abs(L0-C1)) +22.2373*(H1-L1+Abs(H1-C2)+Abs(L1-C2)) +14.8248*(H2-L2+Abs(H2-C3)+Abs(L2-C3)) +9.8832*(H3-L3+Abs(H3-C4)+Abs(L3-C4)) +6.5888*(H4-L4+Abs(H4-C5)+Abs(L4-C5)) +4.3925*(H5-L5+Abs(H5-C6)+Abs(L5-C6)) +2.9284*(H6-L6+Abs(H6-C7)+Abs(L6-C7)) +1.9522*(H7-L7+Abs(H7-C8)+Abs(L7-C8)) +1.3015*(H8-L8+Abs(H8-C9)+Abs(L8-C9)) +.8677*(H9-L9+Abs(H9-C10)+Abs(L9-C10)) +.5784*(H10-L10+Abs(H10-C11)+Abs(L10-C11)) +.3856*(H11-L11+Abs(H11-C12)+Abs(L11-C12)) +.2571*(H12-L12+Abs(H12-C13)+Abs(L12-C13)) +.1714*(H13-L13+Abs(H13-C14)+Abs(L13-C14)) +.1143*(H14-L14+Abs(H14-C15)+Abs(L14-C15)) +.0762*(H15-L15+Abs(H15-C16)+Abs(L15-C16)) +.0508*(H16-L16+Abs(H16-C17)+Abs(L16-C17)) +.0339*(H17-L17+Abs(H17-C18)+Abs(L17-C18)) ) / 2

5dayATR, Wilders Smoothing <0.1% error:
.01*( 20.0198*(H0-L0+Abs(H0-C1)+Abs(L0-C1)) +16.0159*(H1-L1+Abs(H1-C2)+Abs(L1-C2)) +12.8127*(H2-L2+Abs(H2-C3)+Abs(L2-C3)) +10.2502*(H3-L3+Abs(H3-C4)+Abs(L3-C4)) +8.2001*(H4-L4+Abs(H4-C5)+Abs(L4-C5)) +6.5601*(H5-L5+Abs(H5-C6)+Abs(L5-C6)) +5.2481*(H6-L6+Abs(H6-C7)+Abs(L6-C7)) +4.1985*(H7-L7+Abs(H7-C8)+Abs(L7-C8)) +3.3588*(H8-L8+Abs(H8-C9)+Abs(L8-C9)) +2.687*(H9-L9+Abs(H9-C10)+Abs(L9-C10)) +2.1496*(H10-L10+Abs(H10-C11)+Abs(L10-C11)) +1.7197*(H11-L11+Abs(H11-C12)+Abs(L11-C12)) +1.3758*(H12-L12+Abs(H12-C13)+Abs(L12-C13)) +1.1006*(H13-L13+Abs(H13-C14)+Abs(L13-C14)) +.8805*(H14-L14+Abs(H14-C15)+Abs(L14-C15)) +.7044*(H15-L15+Abs(H15-C16)+Abs(L15-C16)) +.5635*(H16-L16+Abs(H16-C17)+Abs(L16-C17)) +.4508*(H17-L17+Abs(H17-C18)+Abs(L17-C18)) +.3606*(H18-L18+Abs(H18-C19)+Abs(L18-C19)) +.2885*(H19-L19+Abs(H19-C20)+Abs(L19-C20)) +.2308*(H20-L20+Abs(H20-C21)+Abs(L20-C21)) +.1847*(H21-L21+Abs(H21-C22)+Abs(L21-C22)) +.1477*(H22-L22+Abs(H22-C23)+Abs(L22-C23)) +.1182*(H23-L23+Abs(H23-C24)+Abs(L23-C24)) +.0945*(H24-L24+Abs(H24-C25)+Abs(L24-C25)) +.0756*(H25-L25+Abs(H25-C26)+Abs(L25-C26)) +.0605*(H26-L26+Abs(H26-C27)+Abs(L26-C27)) +.0484*(H27-L27+Abs(H27-C28)+Abs(L27-C28)) +.0387*(H28-L28+Abs(H28-C29)+Abs(L28-C29)) +.031*(H29-L29+Abs(H29-C30)+Abs(L29-C30)) +.0248*(H30-L30+Abs(H30-C31)+Abs(L30-C31)) ) / 2

10dayATR, Simple MA:
.1*( (H0-L0+Abs(H0-C1)+Abs(L0-C1)) +(H1-L1+Abs(H1-C2)+Abs(L1-C2)) +(H2-L2+Abs(H2-C3)+Abs(L2-C3)) +(H3-L3+Abs(H3-C4)+Abs(L3-C4)) +(H4-L4+Abs(H4-C5)+Abs(L4-C5)) +(H5-L5+Abs(H5-C6)+Abs(L5-C6)) +(H6-L6+Abs(H6-C7)+Abs(L6-C7)) +(H7-L7+Abs(H7-C8)+Abs(L7-C8)) +(H8-L8+Abs(H8-C9)+Abs(L8-C9)) +(H9-L9+Abs(H9-C10)+Abs(L9-C10)) ) / 2

10dayATR, Exponential MA <0.1% error:
.01*( 18.198*(H0-L0+Abs(H0-C1)+Abs(L0-C1)) +14.8893*(H1-L1+Abs(H1-C2)+Abs(L1-C2)) +12.1822*(H2-L2+Abs(H2-C3)+Abs(L2-C3)) +9.9672*(H3-L3+Abs(H3-C4)+Abs(L3-C4)) +8.155*(H4-L4+Abs(H4-C5)+Abs(L4-C5)) +6.6723*(H5-L5+Abs(H5-C6)+Abs(L5-C6)) +5.4591*(H6-L6+Abs(H6-C7)+Abs(L6-C7)) +4.4666*(H7-L7+Abs(H7-C8)+Abs(L7-C8)) +3.6545*(H8-L8+Abs(H8-C9)+Abs(L8-C9)) +2.99*(H9-L9+Abs(H9-C10)+Abs(L9-C10)) +2.4464*(H10-L10+Abs(H10-C11)+Abs(L10-C11)) +2.0016*(H11-L11+Abs(H11-C12)+Abs(L11-C12)) +1.6377*(H12-L12+Abs(H12-C13)+Abs(L12-C13)) +1.3399*(H13-L13+Abs(H13-C14)+Abs(L13-C14)) +1.0963*(H14-L14+Abs(H14-C15)+Abs(L14-C15)) +.897*(H15-L15+Abs(H15-C16)+Abs(L15-C16)) +.7339*(H16-L16+Abs(H16-C17)+Abs(L16-C17)) +.6004*(H17-L17+Abs(H17-C18)+Abs(L17-C18)) +.4913*(H18-L18+Abs(H18-C19)+Abs(L18-C19)) +.4019*(H19-L19+Abs(H19-C20)+Abs(L19-C20)) +.3289*(H20-L20+Abs(H20-C21)+Abs(L20-C21)) +.2691*(H21-L21+Abs(H21-C22)+Abs(L21-C22)) +.2202*(H22-L22+Abs(H22-C23)+Abs(L22-C23)) +.1801*(H23-L23+Abs(H23-C24)+Abs(L23-C24)) +.1474*(H24-L24+Abs(H24-C25)+Abs(L24-C25)) +.1206*(H25-L25+Abs(H25-C26)+Abs(L25-C26)) +.0987*(H26-L26+Abs(H26-C27)+Abs(L26-C27)) +.0807*(H27-L27+Abs(H27-C28)+Abs(L27-C28)) +.066*(H28-L28+Abs(H28-C29)+Abs(L28-C29)) +.054*(H29-L29+Abs(H29-C30)+Abs(L29-C30)) +.0442*(H30-L30+Abs(H30-C31)+Abs(L30-C31)) +.0362*(H31-L31+Abs(H31-C32)+Abs(L31-C32)) +.0296*(H32-L32+Abs(H32-C33)+Abs(L32-C33)) +.0242*(H33-L33+Abs(H33-C34)+Abs(L33-C34)) +.0198*(H34-L34+Abs(H34-C35)+Abs(L34-C35)) ) / 2

10dayATR, Wilder's Smoothing <0.1% error:
.001*( 100.0956*(H0-L0+Abs(H0-C1)+Abs(L0-C1)) +90.086*(H1-L1+Abs(H1-C2)+Abs(L1-C2)) +81.0774*(H2-L2+Abs(H2-C3)+Abs(L2-C3)) +72.9697*(H3-L3+Abs(H3-C4)+Abs(L3-C4)) +65.6727*(H4-L4+Abs(H4-C5)+Abs(L4-C5)) +59.1054*(H5-L5+Abs(H5-C6)+Abs(L5-C6)) +53.1949*(H6-L6+Abs(H6-C7)+Abs(L6-C7)) +47.8754*(H7-L7+Abs(H7-C8)+Abs(L7-C8)) +43.0879*(H8-L8+Abs(H8-C9)+Abs(L8-C9)) +38.7791*(H9-L9+Abs(H9-C10)+Abs(L9-C10)) +34.9012*(H10-L10+Abs(H10-C11)+Abs(L10-C11)) +31.4111*(H11-L11+Abs(H11-C12)+Abs(L11-C12)) +28.27*(H12-L12+Abs(H12-C13)+Abs(L12-C13)) +25.443*(H13-L13+Abs(H13-C14)+Abs(L13-C14)) +22.8987*(H14-L14+Abs(H14-C15)+Abs(L14-C15)) +20.6088*(H15-L15+Abs(H15-C16)+Abs(L15-C16)) +18.5479*(H16-L16+Abs(H16-C17)+Abs(L16-C17)) +16.6931*(H17-L17+Abs(H17-C18)+Abs(L17-C18)) +15.0238*(H18-L18+Abs(H18-C19)+Abs(L18-C19)) +13.5214*(H19-L19+Abs(H19-C20)+Abs(L19-C20)) +12.1693*(H20-L20+Abs(H20-C21)+Abs(L20-C21)) +10.9524*(H21-L21+Abs(H21-C22)+Abs(L21-C22)) +9.8571*(H22-L22+Abs(H22-C23)+Abs(L22-C23)) +8.8714*(H23-L23+Abs(H23-C24)+Abs(L23-C24)) +7.9843*(H24-L24+Abs(H24-C25)+Abs(L24-C25)) +7.1858*(H25-L25+Abs(H25-C26)+Abs(L25-C26)) +6.4673*(H26-L26+Abs(H26-C27)+Abs(L26-C27)) +5.8205*(H27-L27+Abs(H27-C28)+Abs(L27-C28)) +5.2385*(H28-L28+Abs(H28-C29)+Abs(L28-C29)) +4.7146*(H29-L29+Abs(H29-C30)+Abs(L29-C30)) +4.2432*(H30-L30+Abs(H30-C31)+Abs(L30-C31)) +3.8189*(H31-L31+Abs(H31-C32)+Abs(L31-C32)) +3.437*(H32-L32+Abs(H32-C33)+Abs(L32-C33)) +3.0933*(H33-L33+Abs(H33-C34)+Abs(L33-C34)) +2.7839*(H34-L34+Abs(H34-C35)+Abs(L34-C35)) +2.5055*(H35-L35+Abs(H35-C36)+Abs(L35-C36)) +2.255*(H36-L36+Abs(H36-C37)+Abs(L36-C37)) +2.0295*(H37-L37+Abs(H37-C38)+Abs(L37-C38)) +1.8265*(H38-L38+Abs(H38-C39)+Abs(L38-C39)) +1.6439*(H39-L39+Abs(H39-C40)+Abs(L39-C40)) +1.4795*(H40-L40+Abs(H40-C41)+Abs(L40-C41)) +1.3316*(H41-L41+Abs(H41-C42)+Abs(L41-C42)) +1.1984*(H42-L42+Abs(H42-C43)+Abs(L42-C43)) +1.0786*(H43-L43+Abs(H43-C44)+Abs(L43-C44)) +.9707*(H44-L44+Abs(H44-C45)+Abs(L44-C45)) +.8736*(H45-L45+Abs(H45-C46)+Abs(L45-C46)) +.7863*(H46-L46+Abs(H46-C47)+Abs(L46-C47)) +.7076*(H47-L47+Abs(H47-C48)+Abs(L47-C48)) +.6369*(H48-L48+Abs(H48-C49)+Abs(L48-C49)) +.5732*(H49-L49+Abs(H49-C50)+Abs(L49-C50)) +.5159*(H50-L50+Abs(H50-C51)+Abs(L50-C51)) +.4643*(H51-L51+Abs(H51-C52)+Abs(L51-C52)) +.4179*(H52-L52+Abs(H52-C53)+Abs(L52-C53)) +.3761*(H53-L53+Abs(H53-C54)+Abs(L53-C54)) +.3385*(H54-L54+Abs(H54-C55)+Abs(L54-C55)) +.3046*(H55-L55+Abs(H55-C56)+Abs(L55-C56)) +.2742*(H56-L56+Abs(H56-C57)+Abs(L56-C57)) +.2467*(H57-L57+Abs(H57-C58)+Abs(L57-C58)) +.2221*(H58-L58+Abs(H58-C59)+Abs(L58-C59)) +.1999*(H59-L59+Abs(H59-C60)+Abs(L59-C60)) +.1799*(H60-L60+Abs(H60-C61)+Abs(L60-C61)) +.1619*(H61-L61+Abs(H61-C62)+Abs(L61-C62)) +.1457*(H62-L62+Abs(H62-C63)+Abs(L62-C63)) +.1311*(H63-L63+Abs(H63-C64)+Abs(L63-C64)) +.118*(H64-L64+Abs(H64-C65)+Abs(L64-C65)) +.1062*(H65-L65+Abs(H65-C66)+Abs(L65-C66)) ) / 2

Jim Dean

Copyright 2005 by James D. Dean, All Rights Reserved


j2d2
Posted : Thursday, March 10, 2005 10:02:39 PM

Registered User
Joined: 1/14/2005
Posts: 21
Hello James: Thank you for your thoughtful and very detailed reply to my question. And thanks for the bit of history about how Wells Wilder's 1978 definition of ATR did not include the use of a simple moving average as its basis. It was insightful of you to point out that there can be several valid approaches taken in arriving at a solution to this question.
Regards....j2d2
Tanstaafl
Posted : Thursday, March 10, 2005 10:12:55 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
You're very welcome. I'm glad you found it interesting and useful.

Jim Dean

tsisung
Posted : Tuesday, September 12, 2006 11:45:15 PM
Registered User
Joined: 4/3/2005
Posts: 41
Would a 21 day ATR with Wilder's Smoothing just be a ridiculously long PCF?
Tanstaafl
Posted : Wednesday, September 13, 2006 9:20:28 AM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
It would have about 180 days of lookback, to have good accuracy (<.01%). I think it would probably be too slow for most people.

SnapSheets would offer a better, faster alternative.

Jim Dean

Bruce_L
Posted : Wednesday, September 13, 2006 10:50:44 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
tsisung,
I'm not discounting Tanstaafl's SnapSheets recommendation (try it, I think you'll like it), but you may wish to try the following Personal Criteria Formula to see if it is too slow for your tastes. It only uses 142 terms instead of the 180 days Tanstaafl indicated would be required for reasonable accuracy, but it starts by using TeleChart's built in Exponential Moving Average function to calculate an Average Daily Range and then adjusts this value for days where the symbol gapped to get Average True Range. On most actively trading stocks where gaps are not a frequent occurance, the adjustments (constituting most of the PCF) will be fairly minor when compared to the Average Daily Range as calculated using the built in XAVG() function:

XAVGH41 - XAVGL41 + .0476657485943124 * ((H < C1) * (H - C1) + (C1 < L) * (C1 - L) + 20 / 21 * ((H1 < C2) * (H1 - C2) + (C2 < L1) * (C2 - L1) + 20 / 21 * ((H2 < C3) * (H2 - C3) + (C3 < L2) * (C3 - L2) + 20 / 21 * ((H3 < C4) * (H3 - C4) + (C4 < L3) * (C4 - L3) + 20 / 21 * ((H4 < C5) * (H4 - C5) + (C5 < L4) * (C5 - L4) + 20 / 21 * ((H5 < C6) * (H5 - C6) + (C6 < L5) * (C6 - L5) + 20 / 21 * ((H6 < C7) * (H6 - C7) + (C7 < L6) * (C7 - L6) + 20 / 21 * ((H7 < C8) * (H7 - C8) + (C8 < L7) * (C8 - L7) + 20 / 21 * ((H8 < C9) * (H8 - C9) + (C9 < L8) * (C9 - L8) + 20 / 21 * ((H9 < C10) * (H9 - C10) + (C10 < L9) * (C10 - L9) + 20 / 21 * ((H10 < C11) * (H10 - C11) + (C11 < L10) * (C11 - L10) + 20 / 21 * ((H11 < C12) * (H11 - C12) + (C12 < L11) * (C12 - L11) + 20 / 21 * ((H12 < C13) * (H12 - C13) + (C13 < L12) * (C13 - L12) + 20 / 21 * ((H13 < C14) * (H13 - C14) + (C14 < L13) * (C14 - L13) + 20 / 21 * ((H14 < C15) * (H14 - C15) + (C15 < L14) * (C15 - L14) + 20 / 21 * ((H15 < C16) * (H15 - C16) + (C16 < L15) * (C16 - L15) + 20 / 21 * ((H16 < C17) * (H16 - C17) + (C17 < L16) * (C17 - L16) + 20 / 21 * ((H17 < C18) * (H17 - C18) + (C18 < L17) * (C18 - L17) + 20 / 21 * ((H18 < C19) * (H18 - C19) + (C19 < L18) * (C19 - L18) + 20 / 21 * ((H19 < C20) * (H19 - C20) + (C20 < L19) * (C20 - L19) + 20 / 21 * ((H20 < C21) * (H20 - C21) + (C21 < L20) * (C21 - L20) + 20 / 21 * ((H21 < C22) * (H21 - C22) + (C22 < L21) * (C22 - L21) + 20 / 21 * ((H22 < C23) * (H22 - C23) + (C23 < L22) * (C23 - L22) + 20 / 21 * ((H23 < C24) * (H23 - C24) + (C24 < L23) * (C24 - L23) + 20 / 21 * ((H24 < C25) * (H24 - C25) + (C25 < L24) * (C25 - L24) + 20 / 21 * ((H25 < C26) * (H25 - C26) + (C26 < L25) * (C26 - L25) + 20 / 21 * ((H26 < C27) * (H26 - C27) + (C27 < L26) * (C27 - L26) + 20 / 21 * ((H27 < C28) * (H27 - C28) + (C28 < L27) * (C28 - L27) + 20 / 21 * ((H28 < C29) * (H28 - C29) + (C29 < L28) * (C29 - L28) + 20 / 21 * ((H29 < C30) * (H29 - C30) + (C30 < L29) * (C30 - L29) + 20 / 21 * ((H30 < C31) * (H30 - C31) + (C31 < L30) * (C31 - L30) + 20 / 21 * ((H31 < C32) * (H31 - C32) + (C32 < L31) * (C32 - L31) + 20 / 21 * ((H32 < C33) * (H32 - C33) + (C33 < L32) * (C33 - L32) + 20 / 21 * ((H33 < C34) * (H33 - C34) + (C34 < L33) * (C34 - L33) + 20 / 21 * ((H34 < C35) * (H34 - C35) + (C35 < L34) * (C35 - L34) + 20 / 21 * ((H35 < C36) * (H35 - C36) + (C36 < L35) * (C36 - L35) + 20 / 21 * ((H36 < C37) * (H36 - C37) + (C37 < L36) * (C37 - L36) + 20 / 21 * ((H37 < C38) * (H37 - C38) + (C38 < L37) * (C38 - L37) + 20 / 21 * ((H38 < C39) * (H38 - C39) + (C39 < L38) * (C39 - L38) + 20 / 21 * ((H39 < C40) * (H39 - C40) + (C40 < L39) * (C40 - L39) + 20 / 21 * ((H40 < C41) * (H40 - C41) + (C41 < L40) * (C41 - L40) + 20 / 21 * ((H41 < C42) * (H41 - C42) + (C42 < L41) * (C42 - L41) + 20 / 21 * ((H42 < C43) * (H42 - C43) + (C43 < L42) * (C43 - L42) + 20 / 21 * ((H43 < C44) * (H43 - C44) + (C44 < L43) * (C44 - L43) + 20 / 21 * ((H44 < C45) * (H44 - C45) + (C45 < L44) * (C45 - L44) + 20 / 21 * ((H45 < C46) * (H45 - C46) + (C46 < L45) * (C46 - L45) + 20 / 21 * ((H46 < C47) * (H46 - C47) + (C47 < L46) * (C47 - L46) + 20 / 21 * ((H47 < C48) * (H47 - C48) + (C48 < L47) * (C48 - L47) + 20 / 21 * ((H48 < C49) * (H48 - C49) + (C49 < L48) * (C49 - L48) + 20 / 21 * ((H49 < C50) * (H49 - C50) + (C50 < L49) * (C50 - L49) + 20 / 21 * ((H50 < C51) * (H50 - C51) + (C51 < L50) * (C51 - L50) + 20 / 21 * ((H51 < C52) * (H51 - C52) + (C52 < L51) * (C52 - L51) + 20 / 21 * ((H52 < C53) * (H52 - C53) + (C53 < L52) * (C53 - L52) + 20 / 21 * ((H53 < C54) * (H53 - C54) + (C54 < L53) * (C54 - L53) + 20 / 21 * ((H54 < C55) * (H54 - C55) + (C55 < L54) * (C55 - L54) + 20 / 21 * ((H55 < C56) * (H55 - C56) + (C56 < L55) * (C56 - L55) + 20 / 21 * ((H56 < C57) * (H56 - C57) + (C57 < L56) * (C57 - L56) + 20 / 21 * ((H57 < C58) * (H57 - C58) + (C58 < L57) * (C58 - L57) + 20 / 21 * ((H58 < C59) * (H58 - C59) + (C59 < L58) * (C59 - L58) + 20 / 21 * ((H59 < C60) * (H59 - C60) + (C60 < L59) * (C60 - L59) + 20 / 21 * ((H60 < C61) * (H60 - C61) + (C61 < L60) * (C61 - L60) + 20 / 21 * ((H61 < C62) * (H61 - C62) + (C62 < L61) * (C62 - L61) + 20 / 21 * ((H62 < C63) * (H62 - C63) + (C63 < L62) * (C63 - L62) + 20 / 21 * ((H63 < C64) * (H63 - C64) + (C64 < L63) * (C64 - L63) + 20 / 21 * ((H64 < C65) * (H64 - C65) + (C65 < L64) * (C65 - L64) + 20 / 21 * ((H65 < C66) * (H65 - C66) + (C66 < L65) * (C66 - L65) + 20 / 21 * ((H66 < C67) * (H66 - C67) + (C67 < L66) * (C67 - L66) + 20 / 21 * ((H67 < C68) * (H67 - C68) + (C68 < L67) * (C68 - L67) + 20 / 21 * ((H68 < C69) * (H68 - C69) + (C69 < L68) * (C69 - L68) + 20 / 21 * ((H69 < C70) * (H69 - C70) + (C70 < L69) * (C70 - L69) + 20 / 21 * ((H70 < C71) * (H70 - C71) + (C71 < L70) * (C71 - L70) + 20 / 21 * ((H71 < C72) * (H71 - C72) + (C72 < L71) * (C72 - L71) + 20 / 21 * ((H72 < C73) * (H72 - C73) + (C73 < L72) * (C73 - L72) + 20 / 21 * ((H73 < C74) * (H73 - C74) + (C74 < L73) * (C74 - L73) + 20 / 21 * ((H74 < C75) * (H74 - C75) + (C75 < L74) * (C75 - L74) + 20 / 21 * ((H75 < C76) * (H75 - C76) + (C76 < L75) * (C76 - L75) + 20 / 21 * ((H76 < C77) * (H76 - C77) + (C77 < L76) * (C77 - L76) + 20 / 21 * ((H77 < C78) * (H77 - C78) + (C78 < L77) * (C78 - L77) + 20 / 21 * ((H78 < C79) * (H78 - C79) + (C79 < L78) * (C79 - L78) + 20 / 21 * ((H79 < C80) * (H79 - C80) + (C80 < L79) * (C80 - L79) + 20 / 21 * ((H80 < C81) * (H80 - C81) + (C81 < L80) * (C81 - L80) + 20 / 21 * ((H81 < C82) * (H81 - C82) + (C82 < L81) * (C82 - L81) + 20 / 21 * ((H82 < C83) * (H82 - C83) + (C83 < L82) * (C83 - L82) + 20 / 21 * ((H83 < C84) * (H83 - C84) + (C84 < L83) * (C84 - L83) + 20 / 21 * ((H84 < C85) * (H84 - C85) + (C85 < L84) * (C85 - L84) + 20 / 21 * ((H85 < C86) * (H85 - C86) + (C86 < L85) * (C86 - L85) + 20 / 21 * ((H86 < C87) * (H86 - C87) + (C87 < L86) * (C87 - L86) + 20 / 21 * ((H87 < C88) * (H87 - C88) + (C88 < L87) * (C88 - L87) + 20 / 21 * ((H88 < C89) * (H88 - C89) + (C89 < L88) * (C89 - L88) + 20 / 21 * ((H89 < C90) * (H89 - C90) + (C90 < L89) * (C90 - L89) + 20 / 21 * ((H90 < C91) * (H90 - C91) + (C91 < L90) * (C91 - L90) + 20 / 21 * ((H91 < C92) * (H91 - C92) + (C92 < L91) * (C92 - L91) + 20 / 21 * ((H92 < C93) * (H92 - C93) + (C93 < L92) * (C93 - L92) + 20 / 21 * ((H93 < C94) * (H93 - C94) + (C94 < L93) * (C94 - L93) + 20 / 21 * ((H94 < C95) * (H94 - C95) + (C95 < L94) * (C95 - L94) + 20 / 21 * ((H95 < C96) * (H95 - C96) + (C96 < L95) * (C96 - L95) + 20 / 21 * ((H96 < C97) * (H96 - C97) + (C97 < L96) * (C97 - L96) + 20 / 21 * ((H97 < C98) * (H97 - C98) + (C98 < L97) * (C98 - L97) + 20 / 21 * ((H98 < C99) * (H98 - C99) + (C99 < L98) * (C99 - L98) + 20 / 21 * ((H99 < C100) * (H99 - C100) + (C100 < L99) * (C100 - L99) + 20 / 21 * ((H100 < C101) * (H100 - C101) + (C101 < L100) * (C101 - L100) + 20 / 21 * ((H101 < C102) * (H101 - C102) + (C102 < L101) * (C102 - L101) + 20 / 21 * ((H102 < C103) * (H102 - C103) + (C103 < L102) * (C103 - L102) + 20 / 21 * ((H103 < C104) * (H103 - C104) + (C104 < L103) * (C104 - L103) + 20 / 21 * ((H104 < C105) * (H104 - C105) + (C105 < L104) * (C105 - L104) + 20 / 21 * ((H105 < C106) * (H105 - C106) + (C106 < L105) * (C106 - L105) + 20 / 21 * ((H106 < C107) * (H106 - C107) + (C107 < L106) * (C107 - L106) + 20 / 21 * ((H107 < C108) * (H107 - C108) + (C108 < L107) * (C108 - L107) + 20 / 21 * ((H108 < C109) * (H108 - C109) + (C109 < L108) * (C109 - L108) + 20 / 21 * ((H109 < C110) * (H109 - C110) + (C110 < L109) * (C110 - L109) + 20 / 21 * ((H110 < C111) * (H110 - C111) + (C111 < L110) * (C111 - L110) + 20 / 21 * ((H111 < C112) * (H111 - C112) + (C112 < L111) * (C112 - L111) + 20 / 21 * ((H112 < C113) * (H112 - C113) + (C113 < L112) * (C113 - L112) + 20 / 21 * ((H113 < C114) * (H113 - C114) + (C114 < L113) * (C114 - L113) + 20 / 21 * ((H114 < C115) * (H114 - C115) + (C115 < L114) * (C115 - L114) + 20 / 21 * ((H115 < C116) * (H115 - C116) + (C116 < L115) * (C116 - L115) + 20 / 21 * ((H116 < C117) * (H116 - C117) + (C117 < L116) * (C117 - L116) + 20 / 21 * ((H117 < C118) * (H117 - C118) + (C118 < L117) * (C118 - L117) + 20 / 21 * ((H118 < C119) * (H118 - C119) + (C119 < L118) * (C119 - L118) + 20 / 21 * ((H119 < C120) * (H119 - C120) + (C120 < L119) * (C120 - L119) + 20 / 21 * ((H120 < C121) * (H120 - C121) + (C121 < L120) * (C121 - L120) + 20 / 21 * ((H121 < C122) * (H121 - C122) + (C122 < L121) * (C122 - L121) + 20 / 21 * ((H122 < C123) * (H122 - C123) + (C123 < L122) * (C123 - L122) + 20 / 21 * ((H123 < C124) * (H123 - C124) + (C124 < L123) * (C124 - L123) + 20 / 21 * ((H124 < C125) * (H124 - C125) + (C125 < L124) * (C125 - L124) + 20 / 21 * ((H125 < C126) * (H125 - C126) + (C126 < L125) * (C126 - L125) + 20 / 21 * ((H126 < C127) * (H126 - C127) + (C127 < L126) * (C127 - L126) + 20 / 21 * ((H127 < C128) * (H127 - C128) + (C128 < L127) * (C128 - L127) + 20 / 21 * ((H128 < C129) * (H128 - C129) + (C129 < L128) * (C129 - L128) + 20 / 21 * ((H129 < C130) * (H129 - C130) + (C130 < L129) * (C130 - L129) + 20 / 21 * ((H130 < C131) * (H130 - C131) + (C131 < L130) * (C131 - L130) + 20 / 21 * ((H131 < C132) * (H131 - C132) + (C132 < L131) * (C132 - L131) + 20 / 21 * ((H132 < C133) * (H132 - C133) + (C133 < L132) * (C133 - L132) + 20 / 21 * ((H133 < C134) * (H133 - C134) + (C134 < L133) * (C134 - L133) + 20 / 21 * ((H134 < C135) * (H134 - C135) + (C135 < L134) * (C135 - L134) + 20 / 21 * ((H135 < C136) * (H135 - C136) + (C136 < L135) * (C136 - L135) + 20 / 21 * ((H136 < C137) * (H136 - C137) + (C137 < L136) * (C137 - L136) + 20 / 21 * ((H137 < C138) * (H137 - C138) + (C138 < L137) * (C138 - L137) + 20 / 21 * ((H138 < C139) * (H138 - C139) + (C139 < L138) * (C139 - L138) + 20 / 21 * ((H139 < C140) * (H139 - C140) + (C140 < L139) * (C140 - L139) + 20 / 21 * ((H140 < C141) * (H140 - C141) + (C141 < L140) * (C141 - L140) + 20 / 21 * ((H141 < C142) * (H141 - C142) + (C142 < L141) * (C142 - L141)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
tsisung
Posted : Wednesday, September 13, 2006 3:16:01 PM
Registered User
Joined: 4/3/2005
Posts: 41
I'll need to learn how to do it in SnapSheets. Solution above in TeleChart is much too slow.

Thanks.
Bruce_L
Posted : Wednesday, September 13, 2006 3:18:46 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome. You may wish to review the following:

Creating a True Range Block

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
tsisung
Posted : Wednesday, September 13, 2006 4:08:59 PM
Registered User
Joined: 4/3/2005
Posts: 41
I'll watch the video to see if that helps. My goal is to subtract 8x the ATR of the past 21 days from the 10 day high (for longs) and add 5x the ATR of the past 21 to the 10 day low (for shorts) and plot each on a chart.
mikelombardo
Posted : Wednesday, September 13, 2006 6:53:55 PM
Registered User
Joined: 12/30/2004
Posts: 18
When I ran this pcf I got the stocks with a bunch of numbers in the sort column, can you tellme what these numbers mean? This may be simple but I don't unferstand.
Bruce_L
Posted : Wednesday, September 13, 2006 7:07:37 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
True Range is the difference between the Highest and Lowest Price of a symbol from Close to Close including both Closes. Average True Range is the Moving Average of True Range. It is normally Wilder's Smoothed, which is a type of Exponential Moving Average.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Eternum
Posted : Tuesday, October 24, 2006 10:59:24 PM
Registered User
Joined: 8/6/2005
Posts: 40
Tanstaafl,

Could you please provide also 20dayATR, Simple MA?

Thanks!
Craig_S
Posted : Wednesday, October 25, 2006 6:44:08 AM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
Try this:

(((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)+
((H3-L3+ABS(H3-C4)+ABS(L3-C4))/2)+
((H4-L4+ABS(H4-C5)+ABS(L4-C5))/2)+
((H5-L5+ABS(H5-C6)+ABS(L5-C6))/2)+
((H6-L6+ABS(H6-C7)+ABS(L6-C7))/2)+
((H7-L7+ABS(H7-C8)+ABS(L7-C8))/2)+
((H8-L8+ABS(H8-C9)+ABS(L8-C9))/2)+
((H9-L9+ABS(H9-C10)+ABS(L9-C10))/2)+
((H10-L10+ABS(H10-C11)+ABS(L10-C11))/2)+
((H11-L11+ABS(H11-C12)+ABS(L11-C12))/2)+
((H12-L12+ABS(H12-C13)+ABS(L12-C13))/2)+
((H13-L13+ABS(H13-C14)+ABS(L13-C14))/2)+
((H14-L14+ABS(H14-C15)+ABS(L14-C15))/2)+
((H15-L15+ABS(H15-C16)+ABS(L15-C16))/2)+
((H16-L16+ABS(H16-C17)+ABS(L16-C17))/2)+
((H17-L17+ABS(H17-C18)+ABS(L17-C18))/2)+
((H18-L18+ABS(H18-C19)+ABS(L18-C19))/2)+
((H19-L19+ABS(H19-C20)+ABS(L19-C20))/2))/20

- Craig
Here to Help!
Eternum
Posted : Sunday, January 14, 2007 4:50:43 PM
Registered User
Joined: 8/6/2005
Posts: 40
Craig,

Will this formula have similar meaning on weekly chart (20 weeks ATR, simple MA)? Another words, how TeleChart treats, for example, C1? In this closing price of a previous BAR or previous DAY?
Tanstaafl
Posted : Sunday, January 14, 2007 10:53:20 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Hi, Eternum:

First, thank you Craig for helping out.

The answer to the weekly question is NO. PCF's in TC do not interact with the timeframe chosen. If you create a custom indicator with that formula, and then set the chart to weekly, and plot it in the top pane, the databox will show you the current (and past) values of the ATR20 for whatever timeframe is being plotted.

The PCF for a weekly (ie 5-trading-day) calculation must be regenerated, to determine the Open, Close, High and Low of each week, from which the ATR is then calculated.

Here it is:

.05*( (MaxH5.0-MinL5.0+Abs(MaxH5.0-C5)+Abs(MinL5.0-C5)) +(MaxH5.5-MinL5.5+Abs(MaxH5.5-C10)+Abs(MinL5.5-C10)) +(MaxH5.10-MinL5.10+Abs(MaxH5.10-C15)+Abs(MinL5.10-C15)) +(MaxH5.15-MinL5.15+Abs(MaxH5.15-C20)+Abs(MinL5.15-C20)) +(MaxH5.20-MinL5.20+Abs(MaxH5.20-C25)+Abs(MinL5.20-C25)) +(MaxH5.25-MinL5.25+Abs(MaxH5.25-C30)+Abs(MinL5.25-C30)) +(MaxH5.30-MinL5.30+Abs(MaxH5.30-C35)+Abs(MinL5.30-C35)) +(MaxH5.35-MinL5.35+Abs(MaxH5.35-C40)+Abs(MinL5.35-C40)) +(MaxH5.40-MinL5.40+Abs(MaxH5.40-C45)+Abs(MinL5.40-C45)) +(MaxH5.45-MinL5.45+Abs(MaxH5.45-C50)+Abs(MinL5.45-C50)) +(MaxH5.50-MinL5.50+Abs(MaxH5.50-C55)+Abs(MinL5.50-C55)) +(MaxH5.55-MinL5.55+Abs(MaxH5.55-C60)+Abs(MinL5.55-C60)) +(MaxH5.60-MinL5.60+Abs(MaxH5.60-C65)+Abs(MinL5.60-C65)) +(MaxH5.65-MinL5.65+Abs(MaxH5.65-C70)+Abs(MinL5.65-C70)) +(MaxH5.70-MinL5.70+Abs(MaxH5.70-C75)+Abs(MinL5.70-C75)) +(MaxH5.75-MinL5.75+Abs(MaxH5.75-C80)+Abs(MinL5.75-C80)) +(MaxH5.80-MinL5.80+Abs(MaxH5.80-C85)+Abs(MinL5.80-C85)) +(MaxH5.85-MinL5.85+Abs(MaxH5.85-C90)+Abs(MinL5.85-C90)) +(MaxH5.90-MinL5.90+Abs(MaxH5.90-C95)+Abs(MinL5.90-C95)) +(MaxH5.95-MinL5.95+Abs(MaxH5.95-C100)+Abs(MinL5.95-C100)) ) / 2

Jim Dean


Tanstaafl
Posted : Sunday, January 14, 2007 10:56:17 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
My answer may not have been clear.

Use the formula that Craig provided with the Custom Indicator method I described, for ANY timeframe.

Or, use the PCF I supplied AS a PCF (not as a Custom Indicator), for use in EasyScans or a Watchlist Tab column.

If you study my formula carefully, you can see how to modify it for bar-periods other than 5-day "weekly" ones.

Jim Dean

Eternum
Posted : Monday, January 15, 2007 11:55:52 AM
Registered User
Joined: 8/6/2005
Posts: 40
Jim,

Thank you for explanation. My question was about using formula in Custom Indicator rather than in PCF.
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.