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 |

Please provide a description and PCF for calculating an ATR value to be used as a stop loss value Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
gausman
Posted : Friday, July 21, 2006 11:12:45 AM
Registered User
Joined: 12/10/2004
Posts: 10
Bruce_L
Posted : Friday, July 21, 2006 11:28:46 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
True Range is the largest of the High minus the Low, the High minus the previous Close or the previous Close minus the Low. A very useful way of calculating this value for the purpose of creating Personal Criteria Formulas is:

(H -L + ABS(H - C1) + ABS(C1 - L)) / 2

Average True Range is the Moving Average of this value. I'm going to use a Period of 14 because that is what was mentioned in the Thursday, July 20,2006 Worden Report. It could be calculated using a Simple Moving Average:

14-Period Simple Moving Average of True Range:

(AVGH14 - AVGL14) / 2 + (ABS(H - C1) + ABS(C1 - L) + ABS(H1 - C2) + ABS(C2 - L1) + ABS(H2 - C3) + ABS(C3 - L2) + ABS(H3 - C4) + ABS(C4 - L3) + ABS(H4 - C5) + ABS(C5 - L4) + ABS(H5 - C6) + ABS(C6 - L5) + ABS(H6 - C7) + ABS(C7 - L6) + ABS(H7 - C8) + ABS(C8 - L7) + ABS(H8 - C9) + ABS(C9 - L8) + ABS(H9 - C10) + ABS(C10 - L9) + ABS(H10 - C11) + ABS(C11 - L10) + ABS(H11 - C12) + ABS(C12 - L11) + ABS(H12 - C13) + ABS(C13 - L12) + ABS(H13 - C14) + ABS(C14 - L13)) / 28

It is usually calculated using Wilder's Smoothing however. Wilder's Smoothing is a variation of an Exponential Moving Average. You can double the Wilder Period and subtract one to get the Exponential Moving Average Period:

14-Period Average True Range (Wilder's Smoothed):

XAVGH27 - XAVGL27 + .0357480060263825 * (ABS(H - C1) + ABS(L - C1) - H + L + 13 / 14 * (ABS(H1 - C2) + ABS(L1 - C2) - H1 + L1 + 13 / 14 * (ABS(H2 - C3) + ABS(L2 - C3) - H2 + L2 + 13 / 14 * (ABS(H3 - C4) + ABS(L3 - C4) - H3 + L3 + 13 / 14 * (ABS(H4 - C5) + ABS(L4 - C5) - H4 + L4 + 13 / 14 * (ABS(H5 - C6) + ABS(L5 - C6) - H5 + L5 + 13 / 14 * (ABS(H6 - C7) + ABS(L6 - C7) - H6 + L6 + 13 / 14 * (ABS(H7 - C8) + ABS(L7 - C8) - H7 + L7 + 13 / 14 * (ABS(H8 - C9) + ABS(L8 - C9) - H8 + L8 + 13 / 14 * (ABS(H9 - C10) + ABS(L9 - C10) - H9 + L9 + 13 / 14 * (ABS(H10 - C11) + ABS(L10 - C11) - H10 + L10 + 13 / 14 * (ABS(H11 - C12) + ABS(L11 - C12) - H11 + L11 + 13 / 14 * (ABS(H12 - C13) + ABS(L12 - C13) - H12 + L12 + 13 / 14 * (ABS(H13 - C14) + ABS(L13 - C14) - H13 + L13 + 13 / 14 * (ABS(H14 - C15) + ABS(L14 - C15) - H14 + L14 + 13 / 14 * (ABS(H15 - C16) + ABS(L15 - C16) - H15 + L15 + 13 / 14 * (ABS(H16 - C17) + ABS(L16 - C17) - H16 + L16 + 13 / 14 * (ABS(H17 - C18) + ABS(L17 - C18) - H17 + L17 + 13 / 14 * (ABS(H18 - C19) + ABS(L18 - C19) - H18 + L18 + 13 / 14 * (ABS(H19 - C20) + ABS(L19 - C20) - H19 + L19 + 13 / 14 * (ABS(H20 - C21) + ABS(L20 - C21) - H20 + L20 + 13 / 14 * (ABS(H21 - C22) + ABS(L21 - C22) - H21 + L21 + 13 / 14 * (ABS(H22 - C23) + ABS(L22 - C23) - H22 + L22 + 13 / 14 * (ABS(H23 - C24) + ABS(L23 - C24) - H23 + L23 + 13 / 14 * (ABS(H24 - C25) + ABS(L24 - C25) - H24 + L24 + 13 / 14 * (ABS(H25 - C26) + ABS(L25 - C26) - H25 + L25 + 13 / 14 * (ABS(H26 - C27) + ABS(L26 - C27) - H26 + L26 + 13 / 14 * (ABS(H27 - C28) + ABS(L27 - C28) - H27 + L27 + 13 / 14 * (ABS(H28 - C29) + ABS(L28 - C29) - H28 + L28 + 13 / 14 * (ABS(H29 - C30) + ABS(L29 - C30) - H29 + L29 + 13 / 14 * (ABS(H30 - C31) + ABS(L30 - C31) - H30 + L30 + 13 / 14 * (ABS(H31 - C32) + ABS(L31 - C32) - H31 + L31 + 13 / 14 * (ABS(H32 - C33) + ABS(L32 - C33) - H32 + L32 + 13 / 14 * (ABS(H33 - C34) + ABS(L33 - C34) - H33 + L33 + 13 / 14 * (ABS(H34 - C35) + ABS(L34 - C35) - H34 + L34 + 13 / 14 * (ABS(H35 - C36) + ABS(L35 - C36) - H35 + L35 + 13 / 14 * (ABS(H36 - C37) + ABS(L36 - C37) - H36 + L36 + 13 / 14 * (ABS(H37 - C38) + ABS(L37 - C38) - H37 + L37 + 13 / 14 * (ABS(H38 - C39) + ABS(L38 - C39) - H38 + L38 + 13 / 14 * (ABS(H39 - C40) + ABS(L39 - C40) - H39 + L39 + 13 / 14 * (ABS(H40 - C41) + ABS(L40 - C41) - H40 + L40 + 13 / 14 * (ABS(H41 - C42) + ABS(L41 - C42) - H41 + L41 + 13 / 14 * (ABS(H42 - C43) + ABS(L42 - C43) - H42 + L42 + 13 / 14 * (ABS(H43 - C44) + ABS(L43 - C44) - H43 + L43 + 13 / 14 * (ABS(H44 - C45) + ABS(L44 - C45) - H44 + L44 + 13 / 14 * (ABS(H45 - C46) + ABS(L45 - C46) - H45 + L45 + 13 / 14 * (ABS(H46 - C47) + ABS(L46 - C47) - H46 + L46 + 13 / 14 * (ABS(H47 - C48) + ABS(L47 - C48) - H47 + L47 + 13 / 14 * (ABS(H48 - C49) + ABS(L48 - C49) - H48 + L48 + 13 / 14 * (ABS(H49 - C50) + ABS(L49 - C50) - H49 + L49 + 13 / 14 * (ABS(H50 - C51) + ABS(L50 - C51) - H50 + L50 + 13 / 14 * (ABS(H51 - C52) + ABS(L51 - C52) - H51 + L51 + 13 / 14 * (ABS(H52 - C53) + ABS(L52 - C53) - H52 + L52 + 13 / 14 * (ABS(H53 - C54) + ABS(L53 - C54) - H53 + L53 + 13 / 14 * (ABS(H54 - C55) + ABS(L54 - C55) - H54 + L54 + 13 / 14 * (ABS(H55 - C56) + ABS(L55 - C56) - H55 + L55 + 13 / 14 * (ABS(H56 - C57) + ABS(L56 - C57) - H56 + L56 + 13 / 14 * (ABS(H57 - C58) + ABS(L57 - C58) - H57 + L57 + 13 / 14 * (ABS(H58 - C59) + ABS(L58 - C59) - H58 + L58 + 13 / 14 * (ABS(H59 - C60) + ABS(L59 - C60) - H59 + L59 + 13 / 14 * (ABS(H60 - C61) + ABS(L60 - C61) - H60 + L60 + 13 / 14 * (ABS(H61 - C62) + ABS(L61 - C62) - H61 + L61 + 13 / 14 * (ABS(H62 - C63) + ABS(L62 - C63) - H62 + L62 + 13 / 14 * (ABS(H63 - C64) + ABS(L63 - C64) - H63 + L63 + 13 / 14 * (ABS(H64 - C65) + ABS(L64 - C65) - H64 + L64 + 13 / 14 * (ABS(H65 - C66) + ABS(L65 - C66) - H65 + L65 + 13 / 14 * (ABS(H66 - C67) + ABS(L66 - C67) - H66 + L66 + 13 / 14 * (ABS(H67 - C68) + ABS(L67 - C68) - H67 + L67 + 13 / 14 * (ABS(H68 - C69) + ABS(L68 - C69) - H68 + L68 + 13 / 14 * (ABS(H69 - C70) + ABS(L69 - C70) - H69 + L69 + 13 / 14 * (ABS(H70 - C71) + ABS(L70 - C71) - H70 + L70 + 13 / 14 * (ABS(H71 - C72) + ABS(L71 - C72) - H71 + L71 + 13 / 14 * (ABS(H72 - C73) + ABS(L72 - C73) - H72 + L72 + 13 / 14 * (ABS(H73 - C74) + ABS(L73 - C74) - H73 + L73 + 13 / 14 * (ABS(H74 - C75) + ABS(L74 - C75) - H74 + L74 + 13 / 14 * (ABS(H75 - C76) + ABS(L75 - C76) - H75 + L75 + 13 / 14 * (ABS(H76 - C77) + ABS(L76 - C77) - H76 + L76 + 13 / 14 * (ABS(H77 - C78) + ABS(L77 - C78) - H77 + L77 + 13 / 14 * (ABS(H78 - C79) + ABS(L78 - C79) - H78 + L78 + 13 / 14 * (ABS(H79 - C80) + ABS(L79 - C80) - H79 + L79 + 13 / 14 * (ABS(H80 - C81) + ABS(L80 - C81) - H80 + L80 + 13 / 14 * (ABS(H81 - C82) + ABS(L81 - C82) - H81 + L81 + 13 / 14 * (ABS(H82 - C83) + ABS(L82 - C83) - H82 + L82 + 13 / 14 * (ABS(H83 - C84) + ABS(L83 - C84) - H83 + L83 + 13 / 14 * (ABS(H84 - C85) + ABS(L84 - C85) - H84 + L84 + 13 / 14 * (ABS(H85 - C86) + ABS(L85 - C86) - H85 + L85 + 13 / 14 * (ABS(H86 - C87) + ABS(L86 - C87) - H86 + L86 + 13 / 14 * (ABS(H87 - C88) + ABS(L87 - C88) - H87 + L87 + 13 / 14 * (ABS(H88 - C89) + ABS(L88 - C89) - H88 + L88 + 13 / 14 * (ABS(H89 - C90) + ABS(L89 - C90) - H89 + L89 + 13 / 14 * (ABS(H90 - C91) + ABS(L90 - C91) - H90 + L90 + 13 / 14 * (ABS(H91 - C92) + ABS(L91 - C92) - H91 + L91 + 13 / 14 * (ABS(H92 - C93) + ABS(L92 - C93) - H92 + L92 + 13 / 14 * (ABS(H93 - C94) + ABS(L93 - C94) - H93 + L93))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

Here's an Exponential version to round things out:

14-Period Exponential Moving Average of True Range:

XAVGH14 - XAVGL14 + 0.066726791351244 * (ABS(H - C1) + ABS(L - C1) - H + L + 13 / 15 * (ABS(H1 - C2) + ABS(L1 - C2) - H1 + L1 + 13 / 15 * (ABS(H2 - C3) + ABS(L2 - C3) - H2 + L2 + 13 / 15 * (ABS(H3 - C4) + ABS(L3 - C4) - H3 + L3 + 13 / 15 * (ABS(H4 - C5) + ABS(L4 - C5) - H4 + L4 + 13 / 15 * (ABS(H5 - C6) + ABS(L5 - C6) - H5 + L5 + 13 / 15 * (ABS(H6 - C7) + ABS(L6 - C7) - H6 + L6 + 13 / 15 * (ABS(H7 - C8) + ABS(L7 - C8) - H7 + L7 + 13 / 15 * (ABS(H8 - C9) + ABS(L8 - C9) - H8 + L8 + 13 / 15 * (ABS(H9 - C10) + ABS(L9 - C10) - H9 + L9 + 13 / 15 * (ABS(H10 - C11) + ABS(L10 - C11) - H10 + L10 + 13 / 15 * (ABS(H11 - C12) + ABS(L11 - C12) - H11 + L11 + 13 / 15 * (ABS(H12 - C13) + ABS(L12 - C13) - H12 + L12 + 13 / 15 * (ABS(H13 - C14) + ABS(L13 - C14) - H13 + L13 + 13 / 15 * (ABS(H14 - C15) + ABS(L14 - C15) - H14 + L14 + 13 / 15 * (ABS(H15 - C16) + ABS(L15 - C16) - H15 + L15 + 13 / 15 * (ABS(H16 - C17) + ABS(L16 - C17) - H16 + L16 + 13 / 15 * (ABS(H17 - C18) + ABS(L17 - C18) - H17 + L17 + 13 / 15 * (ABS(H18 - C19) + ABS(L18 - C19) - H18 + L18 + 13 / 15 * (ABS(H19 - C20) + ABS(L19 - C20) - H19 + L19 + 13 / 15 * (ABS(H20 - C21) + ABS(L20 - C21) - H20 + L20 + 13 / 15 * (ABS(H21 - C22) + ABS(L21 - C22) - H21 + L21 + 13 / 15 * (ABS(H22 - C23) + ABS(L22 - C23) - H22 + L22 + 13 / 15 * (ABS(H23 - C24) + ABS(L23 - C24) - H23 + L23 + 13 / 15 * (ABS(H24 - C25) + ABS(L24 - C25) - H24 + L24 + 13 / 15 * (ABS(H25 - C26) + ABS(L25 - C26) - H25 + L25 + 13 / 15 * (ABS(H26 - C27) + ABS(L26 - C27) - H26 + L26 + 13 / 15 * (ABS(H27 - C28) + ABS(L27 - C28) - H27 + L27 + 13 / 15 * (ABS(H28 - C29) + ABS(L28 - C29) - H28 + L28 + 13 / 15 * (ABS(H29 - C30) + ABS(L29 - C30) - H29 + L29 + 13 / 15 * (ABS(H30 - C31) + ABS(L30 - C31) - H30 + L30 + 13 / 15 * (ABS(H31 - C32) + ABS(L31 - C32) - H31 + L31 + 13 / 15 * (ABS(H32 - C33) + ABS(L32 - C33) - H32 + L32 + 13 / 15 * (ABS(H33 - C34) + ABS(L33 - C34) - H33 + L33 + 13 / 15 * (ABS(H34 - C35) + ABS(L34 - C35) - H34 + L34 + 13 / 15 * (ABS(H35 - C36) + ABS(L35 - C36) - H35 + L35 + 13 / 15 * (ABS(H36 - C37) + ABS(L36 - C37) - H36 + L36 + 13 / 15 * (ABS(H37 - C38) + ABS(L37 - C38) - H37 + L37 + 13 / 15 * (ABS(H38 - C39) + ABS(L38 - C39) - H38 + L38 + 13 / 15 * (ABS(H39 - C40) + ABS(L39 - C40) - H39 + L39 + 13 / 15 * (ABS(H40 - C41) + ABS(L40 - C41) - H40 + L40 + 13 / 15 * (ABS(H41 - C42) + ABS(L41 - C42) - H41 + L41 + 13 / 15 * (ABS(H42 - C43) + ABS(L42 - C43) - H42 + L42 + 13 / 15 * (ABS(H43 - C44) + ABS(L43 - C44) - H43 + L43 + 13 / 15 * (ABS(H44 - C45) + ABS(L44 - C45) - H44 + L44 + 13 / 15 * (ABS(H45 - C46) + ABS(L45 - C46) - H45 + L45 + 13 / 15 * (ABS(H46 - C47) + ABS(L46 - C47) - H46 + L46 + 13 / 15 * (ABS(H47 - C48) + ABS(L47 - C48) - H47 + L47 + 13 / 15 * (ABS(H48 - C49) + ABS(L48 - C49) - H48 + L48)))))))))))))))))))))))))))))))))))))))))))))))))

You may wish to review the following:

How to create a Personal Criteria Forumula (PCF)
Handy PCF example formulas to help you learn the syntax of PCFs!

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
HokieTrader
Posted : Saturday, October 14, 2006 12:15:00 AM
Registered User
Joined: 9/23/2006
Posts: 5
QUOTE (Bruce_L)
Average True Range is the Moving Average of this value. I'm going to use a Period of 14 because that is what was mentioned in the Thursday, July 20,2006 Worden Report. It could be calculated using a Simple Moving Average:

14-Period Simple Moving Average of True Range:

(AVGH14 - AVGL14) / 2 + (ABS(H - C1) + ABS(C1 - L) + ABS(H1 - C2) + ABS(C2 - L1) + ABS(H2 - C3) + ABS(C3 - L2) + ABS(H3 - C4) + ABS(C4 - L3) + ABS(H4 - C5) + ABS(C5 - L4) + ABS(H5 - C6) + ABS(C6 - L5) + ABS(H6 - C7) + ABS(C7 - L6) + ABS(H7 - C8) + ABS(C8 - L7) + ABS(H8 - C9) + ABS(C9 - L8) + ABS(H9 - C10) + ABS(C10 - L9) + ABS(H10 - C11) + ABS(C11 - L10) + ABS(H11 - C12) + ABS(C12 - L11) + ABS(H12 - C13) + ABS(C13 - L12) + ABS(H13 - C14) + ABS(C14 - L13)) / 28



Bruce-
What's the difference between the simple moving average of ATR formula you list above and using TeleChart to do the moving average the way you describe in Average True Range (ATR)? Thanks.
Bruce_L
Posted : Saturday, October 14, 2006 9:29:26 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
HokieTrader,
The method described in the topic you referenced is designed to plot a Wilder's Smoothed Average True Range on the chart using a Custom Indicator. The Period is adjustable, but with an Average Period of 27 and Exponential Smoothing, the chart should match the results of the 14-Period Average True Range (Wilder's Smoothed) Personal Criteria Formula above.

It will not match the results of a 14-Period Simple Moving Average of True Range or a 14-Period Exponential Moving Average of True Range, but both could be charted as well. To plot a 14-Period Simple Moving Average of True Range, use an Average Period of 14 and an Average Type of Simple. To plot a 14-Period Exponential Moving Average of True Range, use an Average Period of 14 and an Average Type of Exponential.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
HokieTrader
Posted : Saturday, October 14, 2006 9:53:10 AM
Registered User
Joined: 9/23/2006
Posts: 5
Bruce, thanks for the quick response, but I'm still confused. Are the following two equivalent ways to plot average true range (forget for a minute that the first example is exponential, let's assume it's simple and same period as second example)? Do you need to use smoothing average of 27 for the second example, or is that built into the formula? Thanks again. Ed

QUOTE (Bruce_L)
Average True Range is not one of TeleChart's built in indicators, but it can be created as a Custom Indicator. Please try the following for a 20-Period ATR:

Select Chart Template | Add Indicator | Indicator.
- Visible: Checked
- Center Zero Line: Checked
- Plot using price scale: Unchecked
- Smoothing Average: 39 (twice the ATR-Period minus one)
- Average Type: Exponential
- Indicator Formula: (H - L + ABS(H - C1) + ABS(L - C1)) / 2

You can adjust the Average True Range Period by changing the Smoothing Average in the Custom Indicator. For example, to plot a 14-Period ATR, just change the Smoothing Average to 27 (which equals (14 * 2) -1).


QUOTE (Bruce_L)
True Range is the largest of the High minus the Low, the High minus the previous Close or the previous Close minus the Low. A very useful way of calculating this value for the purpose of creating Personal Criteria Formulas is:

(H -L + ABS(H - C1) + ABS(C1 - L)) / 2

Average True Range is the Moving Average of this value. I'm going to use a Period of 14 because that is what was mentioned in the Thursday, July 20,2006 Worden Report. It could be calculated using a Simple Moving Average:

14-Period Simple Moving Average of True Range:

(AVGH14 - AVGL14) / 2 + (ABS(H - C1) + ABS(C1 - L) + ABS(H1 - C2) + ABS(C2 - L1) + ABS(H2 - C3) + ABS(C3 - L2) + ABS(H3 - C4) + ABS(C4 - L3) + ABS(H4 - C5) + ABS(C5 - L4) + ABS(H5 - C6) + ABS(C6 - L5) + ABS(H6 - C7) + ABS(C7 - L6) + ABS(H7 - C8) + ABS(C8 - L7) + ABS(H8 - C9) + ABS(C9 - L8) + ABS(H9 - C10) + ABS(C10 - L9) + ABS(H10 - C11) + ABS(C11 - L10) + ABS(H11 - C12) + ABS(C12 - L11) + ABS(H12 - C13) + ABS(C13 - L12) + ABS(H13 - C14) + ABS(C14 - L13)) / 28
Bruce_L
Posted : Saturday, October 14, 2006 10:21:10 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (HokieTrader)
Are the following two equivalent ways to plot average true range?

The first is a Custom Indicator designed to plot Average True Range in a way that can be easily customized by changing the Smoothing Average and Average Type.

The second is a Personal Criteria Formula with a 14-Period Simple Moving Average built in designed for use as a Sort or EasyScan Condition. While it is possible to use this formula as a Custom Indicator (note the Smoothing Average of 1):

Select Chart Template | Add Indicator | Indicator.
- Visible: Checked
- Center Zero Line: Checked
- Plot using price scale: Unchecked
- Smoothing Average: 1
- Average Type: Doesn't matter (because the Smoothing Average is 1).
- Indicator Formula: (AVGH14 - AVGL14) / 2 + (ABS(H - C1) + ABS(C1 - L) + ABS(H1 - C2) + ABS(C2 - L1) + ABS(H2 - C3) + ABS(C3 - L2) + ABS(H3 - C4) + ABS(C4 - L3) + ABS(H4 - C5) + ABS(C5 - L4) + ABS(H5 - C6) + ABS(C6 - L5) + ABS(H6 - C7) + ABS(C7 - L6) + ABS(H7 - C8) + ABS(C8 - L7) + ABS(H8 - C9) + ABS(C9 - L8) + ABS(H9 - C10) + ABS(C10 - L9) + ABS(H10 - C11) + ABS(C11 - L10) + ABS(H11 - C12) + ABS(C12 - L11) + ABS(H12 - C13) + ABS(C13 - L12) + ABS(H13 - C14) + ABS(C14 - L13)) / 28

The same result can be done achieved more efficiently as follows:

Select Chart Template | Add Indicator | Indicator.
- Visible: Checked
- Center Zero Line: Checked
- Plot using price scale: Unchecked
- Smoothing Average: 14
- Average Type: Simple
- Indicator Formula: (H - L + ABS(H - C1) + ABS(L - C1)) / 2

QUOTE (HokieTrader)
(forget for a minute that the first example is exponential, let's assume it's simple and same period as second example)? Do you need to use smoothing average of 27 for the second example, or is that built into the formula?

The entire point of using 27 instead of 14 for the Smoothing Average is a result of the type of Smoothing used. Average True Range almost always uses Wilder's Smoothing because it was developed by Welles Wilder (this is also where the commonly used period of 14 comes from). Wilder's Smoothing is actually a type of Exponential Smoothing. It is possible to reproduce Wilder's Smoothing using Exponential Smoothing by multiplying the Wilder's Period by two and then subtracting one.

A 14-Period Simple Moving Average of True Range would use a Smoothing Average of 14 and an Average Type of Simple.
A 14-Period Exponential Moving Average of True Range would use a Smoothing Average of 14 and an Average Type of Exponential.
A 14-Period Wilder's Smoothed Average True Range would use a Smoothing Average of 27 and an Average Type of Exponential.

You may wish to review the following:

Plotting Custom Indicators with Examples
How to create a Personal Criteria Forumula (PCF)
Create your own stock rankings using WatchLists and Sort conditions
Using EasyScan to find stocks that meet your own criteria

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
HokieTrader
Posted : Saturday, October 14, 2006 11:56:24 AM
Registered User
Joined: 9/23/2006
Posts: 5
Bruce, got it, thanks for clarifying this!
Nimbus
Posted : Sunday, October 15, 2006 10:46:56 AM

Registered User
Joined: 2/9/2005
Posts: 42
OK, so now that we have the ATR, how should it be best applied to act as a trailing Stop Loss? Apply it below the prior day's close, low, or one of the moving averages?

Thanks.
Bruce_L
Posted : Sunday, October 15, 2006 10:04:11 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Nimbus,
The trainers cannot give settings, interpretation or investment advice. You may wish to review the following:

Average True Range (ATR) & Stop Losses
Trailing-Stop Applications in TC

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
jfh123
Posted : Monday, November 19, 2007 11:18:08 AM
Registered User
Joined: 12/17/2004
Posts: 143
QUOTE (Bruce_L)
True Range is the largest of the High minus the Low, the High minus the previous Close or the previous Close minus the Low. A very useful way of calculating this value for the purpose of creating Personal Criteria Formulas is:

(H -L + ABS(H - C1) + ABS(C1 - L)) / 2

Average True Range is the Moving Average of this value.
How to create a Personal Criteria Forumula (PCF)
Handy PCF example formulas to help you learn the syntax of PCFs!


I feel really silly asking, but .... if I don't ask, I can't learn.

Bruce, above you divide three differences by the number 2.  Why not 3, if we want an average?
Bruce_L
Posted : Monday, November 19, 2007 11:35:29 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
jfh123,
The reason is that we are not actually trying to get an average of H - L, ABS(H - C1) and ABS(C1 - L).

There are three possible situations that need to be dealt with when writing the formula for True Range.

1 - Yesterday's Close is above today's range.
2 - Yesterday's Close is within today's range.
3 - Yesterday's Close is below today's range.

If yesterday's close is above today's range:

H - L is today's Range.
ABS(H - C1) = C1 - H
ABS(C1 - L) = C1 - L = C1 - H + H - L

Adding these three together results in:

2 * (C1 - H) + 2 * (H - L) = 2 * (C1 - L)

If yesterday's close is within today's range:

H - L is today's Range.
ABS(H - C1) = H - C1
ABS(C1 - L) = C1 - L

Adding these three together results in:

H - L + H - C1 + C1 - L = 2 * (H - L)

If yesterday's close is below today's range:

H - L is today's Range.
ABS(H - C1) = H - C1 = H - L + L - C1
ABS(C1 - L) = L - C1

Adding these three together results in:

2 * (L - C1) + 2 * (H - L) = 2 * (H - C1)

In all three cases, the result is twice the True Range (which is why we divide by two).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
jfh123
Posted : Monday, November 19, 2007 1:23:41 PM
Registered User
Joined: 12/17/2004
Posts: 143
B-


Very clear.  Thanks!

J
Bruce_L
Posted : Monday, November 19, 2007 1:24:38 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
jfh123,
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
awshucks
Posted : Friday, May 9, 2008 7:02:31 AM
Registered User
Joined: 1/28/2006
Posts: 291
Given all the above Bruce, how would one design a PCF to figure out whether the ATR of an issue is within striking distance of its price on a given day (used as a benchmark)?  Having tried to do so several times, I have been frustrated by the system assigning a syntax error if I enter the day in question more than twice.  (I think did verify by reducing the code to the point where it errored).   

Lets assume the ATR is 20 and that it is not the third entry of the day that is at fault, but my weakness in writing decent code. ;~)  Thanks in advance for your time.
Bruce_L
Posted : Friday, May 9, 2008 9:54:08 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
awshucks,
I don't actually understand the specifics of what you are attempting. If you provide more details, we may be able to help.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
awshucks
Posted : Friday, May 9, 2008 11:28:59 AM
Registered User
Joined: 1/28/2006
Posts: 291
I would like to plot when the closing price of an issue (c1) comes back within the 20d ATR range of a past closing price.  Does this make more sense? 
Bruce_L
Posted : Friday, May 9, 2008 11:46:43 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
awshucks,
I still don't think I understand the request, but assuming you are actually correct in using C1 and mean yesterday's Closing Price and not the Current or Last Closing Price (which would be C), you can find the difference between C1 and an arbitrary date using a date in single quotes instead of a Days Ago parameter. For example, if you wanted to specify the difference between yesterday and May 6, 2008, you could write it as follows:

C1 - C'05/06/08'

If you wanted that to be less than a 20-Period Average True Range, you would write:

C1 - C'05/06/08' < x

Where x is replaced with one of the formulas from the 20-Day Average True Range topic. Depending on which you want to be higher, you may need to reverse the formula:

C'05/06/08' - C1

If you don't care about the which is higher (you just want the proximity), you could use an absolute value function:

ABS(C1 - C'05/06/08')

You may wish to review the following:

PCF Formula Descriptions

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
awshucks
Posted : Friday, May 9, 2008 2:12:56 PM
Registered User
Joined: 1/28/2006
Posts: 291

Ok, thanks...yes proximity is what I wish to measure and have not used absolute function before.  The descriptions only help so much.  thanx.

Bruce_L
Posted : Friday, May 9, 2008 2:18:06 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
awshucks,
Then if I'm understanding correctly, you will want to use:

ABS(C1 - C'05/06/08') < x

Where x is replaced with one of the formulas from the 20-Day Average True Range topic.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
awshucks
Posted : Friday, May 9, 2008 4:04:35 PM
Registered User
Joined: 1/28/2006
Posts: 291

Got it working...thanx again for the help Bruce.

gotafish
Posted : Thursday, July 3, 2008 12:17:24 PM
Registered User
Joined: 12/30/2004
Posts: 10
I know this is an old post but I am hopeful that someone can still answer my question. I took the formula from Bruce. The 14-Period Average True Range (Wilder's Smoothed) and pasted it into my Personal Criteria Formula's. What I am hopeful to do is to use this ATR with different multiples. I have tried adding the *2 numerous times to the formula in different places without any luck. Could someone please help me in getting this done. I would like to be able to easily change the ATR to any multiple I choose 1.5X  2.0X or even 3.0X.

I am in the process of testing the Blocks new BackScanner feature and would like to use this formula as a STOP LOSS to do some backtesting. Any help is greatly appreciated.

Greg V.
Bruce_L
Posted : Thursday, July 3, 2008 12:35:46 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
gotafish,
You would want to place parentheses around the formula and then add the times two:

(your formula goes here) * 2

In any case, these formulas are written in TeleChart's Personal Criteria Formula Language and will not work in Blocks. You may want to take a look at the Indicator Stops Blocks3 topic.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
gotafish
Posted : Thursday, July 3, 2008 12:51:24 PM
Registered User
Joined: 12/30/2004
Posts: 10
Thanks for the quick reply back. I did as instructed. I originally ran this on the symbol QID and came up with an ATR of 1.84. I wanted to times this by 2. so I took your formula as instructed and when I ran it after adding the parentheses and *2 the ATR came out to be 3.67 which is really not 2X1.84. What happened? Confused!! Here is the formula I used.

14-Period Average True Range (Wilder's Smoothed):

(XAVGH27 - XAVGL27 + .0357480060263825 * (ABS(H - C1) + ABS(L - C1) - H + L + 13 / 14 * (ABS(H1 - C2) + ABS(L1 - C2) - H1 + L1 + 13 / 14 * (ABS(H2 - C3) + ABS(L2 - C3) - H2 + L2 + 13 / 14 * (ABS(H3 - C4) + ABS(L3 - C4) - H3 + L3 + 13 / 14 * (ABS(H4 - C5) + ABS(L4 - C5) - H4 + L4 + 13 / 14 * (ABS(H5 - C6) + ABS(L5 - C6) - H5 + L5 + 13 / 14 * (ABS(H6 - C7) + ABS(L6 - C7) - H6 + L6 + 13 / 14 * (ABS(H7 - C8) + ABS(L7 - C8) - H7 + L7 + 13 / 14 * (ABS(H8 - C9) + ABS(L8 - C9) - H8 + L8 + 13 / 14 * (ABS(H9 - C10) + ABS(L9 - C10) - H9 + L9 + 13 / 14 * (ABS(H10 - C11) + ABS(L10 - C11) - H10 + L10 + 13 / 14 * (ABS(H11 - C12) + ABS(L11 - C12) - H11 + L11 + 13 / 14 * (ABS(H12 - C13) + ABS(L12 - C13) - H12 + L12 + 13 / 14 * (ABS(H13 - C14) + ABS(L13 - C14) - H13 + L13 + 13 / 14 * (ABS(H14 - C15) + ABS(L14 - C15) - H14 + L14 + 13 / 14 * (ABS(H15 - C16) + ABS(L15 - C16) - H15 + L15 + 13 / 14 * (ABS(H16 - C17) + ABS(L16 - C17) - H16 + L16 + 13 / 14 * (ABS(H17 - C18) + ABS(L17 - C18) - H17 + L17 + 13 / 14 * (ABS(H18 - C19) + ABS(L18 - C19) - H18 + L18 + 13 / 14 * (ABS(H19 - C20) + ABS(L19 - C20) - H19 + L19 + 13 / 14 * (ABS(H20 - C21) + ABS(L20 - C21) - H20 + L20 + 13 / 14 * (ABS(H21 - C22) + ABS(L21 - C22) - H21 + L21 + 13 / 14 * (ABS(H22 - C23) + ABS(L22 - C23) - H22 + L22 + 13 / 14 * (ABS(H23 - C24) + ABS(L23 - C24) - H23 + L23 + 13 / 14 * (ABS(H24 - C25) + ABS(L24 - C25) - H24 + L24 + 13 / 14 * (ABS(H25 - C26) + ABS(L25 - C26) - H25 + L25 + 13 / 14 * (ABS(H26 - C27) + ABS(L26 - C27) - H26 + L26 + 13 / 14 * (ABS(H27 - C28) + ABS(L27 - C28) - H27 + L27 + 13 / 14 * (ABS(H28 - C29) + ABS(L28 - C29) - H28 + L28 + 13 / 14 * (ABS(H29 - C30) + ABS(L29 - C30) - H29 + L29 + 13 / 14 * (ABS(H30 - C31) + ABS(L30 - C31) - H30 + L30 + 13 / 14 * (ABS(H31 - C32) + ABS(L31 - C32) - H31 + L31 + 13 / 14 * (ABS(H32 - C33) + ABS(L32 - C33) - H32 + L32 + 13 / 14 * (ABS(H33 - C34) + ABS(L33 - C34) - H33 + L33 + 13 / 14 * (ABS(H34 - C35) + ABS(L34 - C35) - H34 + L34 + 13 / 14 * (ABS(H35 - C36) + ABS(L35 - C36) - H35 + L35 + 13 / 14 * (ABS(H36 - C37) + ABS(L36 - C37) - H36 + L36 + 13 / 14 * (ABS(H37 - C38) + ABS(L37 - C38) - H37 + L37 + 13 / 14 * (ABS(H38 - C39) + ABS(L38 - C39) - H38 + L38 + 13 / 14 * (ABS(H39 - C40) + ABS(L39 - C40) - H39 + L39 + 13 / 14 * (ABS(H40 - C41) + ABS(L40 - C41) - H40 + L40 + 13 / 14 * (ABS(H41 - C42) + ABS(L41 - C42) - H41 + L41 + 13 / 14 * (ABS(H42 - C43) + ABS(L42 - C43) - H42 + L42 + 13 / 14 * (ABS(H43 - C44) + ABS(L43 - C44) - H43 + L43 + 13 / 14 * (ABS(H44 - C45) + ABS(L44 - C45) - H44 + L44 + 13 / 14 * (ABS(H45 - C46) + ABS(L45 - C46) - H45 + L45 + 13 / 14 * (ABS(H46 - C47) + ABS(L46 - C47) - H46 + L46 + 13 / 14 * (ABS(H47 - C48) + ABS(L47 - C48) - H47 + L47 + 13 / 14 * (ABS(H48 - C49) + ABS(L48 - C49) - H48 + L48 + 13 / 14 * (ABS(H49 - C50) + ABS(L49 - C50) - H49 + L49 + 13 / 14 * (ABS(H50 - C51) + ABS(L50 - C51) - H50 + L50 + 13 / 14 * (ABS(H51 - C52) + ABS(L51 - C52) - H51 + L51 + 13 / 14 * (ABS(H52 - C53) + ABS(L52 - C53) - H52 + L52 + 13 / 14 * (ABS(H53 - C54) + ABS(L53 - C54) - H53 + L53 + 13 / 14 * (ABS(H54 - C55) + ABS(L54 - C55) - H54 + L54 + 13 / 14 * (ABS(H55 - C56) + ABS(L55 - C56) - H55 + L55 + 13 / 14 * (ABS(H56 - C57) + ABS(L56 - C57) - H56 + L56 + 13 / 14 * (ABS(H57 - C58) + ABS(L57 - C58) - H57 + L57 + 13 / 14 * (ABS(H58 - C59) + ABS(L58 - C59) - H58 + L58 + 13 / 14 * (ABS(H59 - C60) + ABS(L59 - C60) - H59 + L59 + 13 / 14 * (ABS(H60 - C61) + ABS(L60 - C61) - H60 + L60 + 13 / 14 * (ABS(H61 - C62) + ABS(L61 - C62) - H61 + L61 + 13 / 14 * (ABS(H62 - C63) + ABS(L62 - C63) - H62 + L62 + 13 / 14 * (ABS(H63 - C64) + ABS(L63 - C64) - H63 + L63 + 13 / 14 * (ABS(H64 - C65) + ABS(L64 - C65) - H64 + L64 + 13 / 14 * (ABS(H65 - C66) + ABS(L65 - C66) - H65 + L65 + 13 / 14 * (ABS(H66 - C67) + ABS(L66 - C67) - H66 + L66 + 13 / 14 * (ABS(H67 - C68) + ABS(L67 - C68) - H67 + L67 + 13 / 14 * (ABS(H68 - C69) + ABS(L68 - C69) - H68 + L68 + 13 / 14 * (ABS(H69 - C70) + ABS(L69 - C70) - H69 + L69 + 13 / 14 * (ABS(H70 - C71) + ABS(L70 - C71) - H70 + L70 + 13 / 14 * (ABS(H71 - C72) + ABS(L71 - C72) - H71 + L71 + 13 / 14 * (ABS(H72 - C73) + ABS(L72 - C73) - H72 + L72 + 13 / 14 * (ABS(H73 - C74) + ABS(L73 - C74) - H73 + L73 + 13 / 14 * (ABS(H74 - C75) + ABS(L74 - C75) - H74 + L74 + 13 / 14 * (ABS(H75 - C76) + ABS(L75 - C76) - H75 + L75 + 13 / 14 * (ABS(H76 - C77) + ABS(L76 - C77) - H76 + L76 + 13 / 14 * (ABS(H77 - C78) + ABS(L77 - C78) - H77 + L77 + 13 / 14 * (ABS(H78 - C79) + ABS(L78 - C79) - H78 + L78 + 13 / 14 * (ABS(H79 - C80) + ABS(L79 - C80) - H79 + L79 + 13 / 14 * (ABS(H80 - C81) + ABS(L80 - C81) - H80 + L80 + 13 / 14 * (ABS(H81 - C82) + ABS(L81 - C82) - H81 + L81 + 13 / 14 * (ABS(H82 - C83) + ABS(L82 - C83) - H82 + L82 + 13 / 14 * (ABS(H83 - C84) + ABS(L83 - C84) - H83 + L83 + 13 / 14 * (ABS(H84 - C85) + ABS(L84 - C85) - H84 + L84 + 13 / 14 * (ABS(H85 - C86) + ABS(L85 - C86) - H85 + L85 + 13 / 14 * (ABS(H86 - C87) + ABS(L86 - C87) - H86 + L86 + 13 / 14 * (ABS(H87 - C88) + ABS(L87 - C88) - H87 + L87 + 13 / 14 * (ABS(H88 - C89) + ABS(L88 - C89) - H88 + L88 + 13 / 14 * (ABS(H89 - C90) + ABS(L89 - C90) - H89 + L89 + 13 / 14 * (ABS(H90 - C91) + ABS(L90 - C91) - H90 + L90 + 13 / 14 * (ABS(H91 - C92) + ABS(L91 - C92) - H91 + L91 + 13 / 14 * (ABS(H92 - C93) + ABS(L92 - C93) - H92 + L92 + 13 / 14 * (ABS(H93 - C94) + ABS(L93 - C94) - H93 + L93)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))*2
Bruce_L
Posted : Thursday, July 3, 2008 1:09:21 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
gotafish,
It's just a rounding issue resulting from the value being displayed to two digits past the decimal. I'm getting the following when calculating to more decimal places when updated through 07/02/2008 01:00 PM ET (Data delayed at least 20 min):

Times one: 1.836 - which rounds to: 1.84
Times Two: 3.672 - which rounds to: 3.67

This is entirely consistent with your results. I'm only partially joking when I say that 2 + 2 = 5 for exceptionally large values of 2.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
gotafish
Posted : Thursday, July 3, 2008 1:26:08 PM
Registered User
Joined: 12/30/2004
Posts: 10
Sorry about that last comment. My math wasn't too good. I can't even multiply 1.84 X 2   :-)   Your formula and instructions worked perfectly. Thank you so much for your help. It is greatly appreciated.

Greg V
Bruce_L
Posted : Thursday, July 3, 2008 1:32:36 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
gotafish,
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
ERhodes
Posted : Monday, February 9, 2009 12:09:47 PM
Registered User
Joined: 10/27/2008
Posts: 6
ATR 30
Bruce_L
Posted : Monday, February 9, 2009 12:14:45 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
ERhodes,
It was one of the links I referenced when I answered your original question in Average True Range:

ATR for PCF

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
dulakovic
Posted : Friday, April 29, 2011 12:13:49 AM
Registered User
Joined: 11/29/2006
Posts: 181
Bruce, Can you please post a PCF for 20-Period Simple Moving Average of True Range (to be used in easy scan).
Tx
Bruce_L
Posted : Friday, April 29, 2011 7:38:14 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The 20-Day Average True Range topic contains Personal Criteria Formulas for all three interpretations of a 20-Period Average True Range.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
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.