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 |

custom pdf for average true range Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
thoric
Posted : Tuesday, October 7, 2008 2:56:23 PM
Registered User
Joined: 1/7/2008
Posts: 4
hi-

how do I find out the ATR of a stock?

i would like to get the average true range (ATR) for different stocks on a 9 day period and post it my charts.

thanks,

thoric

Bruce_L
Posted : Tuesday, October 7, 2008 3:10:07 PM


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. It could be calculated using a Simple Moving Average:

9-Period Simple Moving Average of True Range:

(AVGH9 - AVGL9) / 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)) / 18

This could be Plotted as a Custom Indicator as follows:

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

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:

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

XAVGH17 - XAVGL17 + .111217813840782 * ((H < C1) * (H - C1) + (C1 < L) * (C1 - L) + 8 / 9 * ((H1 < C2) * (H1 - C2) + (C2 < L1) * (C2 - L1) + 8 / 9 * ((H2 < C3) * (H2 - C3) + (C3 < L2) * (C3 - L2) + 8 / 9 * ((H3 < C4) * (H3 - C4) + (C4 < L3) * (C4 - L3) + 8 / 9 * ((H4 < C5) * (H4 - C5) + (C5 < L4) * (C5 - L4) + 8 / 9 * ((H5 < C6) * (H5 - C6) + (C6 < L5) * (C6 - L5) + 8 / 9 * ((H6 < C7) * (H6 - C7) + (C7 < L6) * (C7 - L6) + 8 / 9 * ((H7 < C8) * (H7 - C8) + (C8 < L7) * (C8 - L7) + 8 / 9 * ((H8 < C9) * (H8 - C9) + (C9 < L8) * (C9 - L8) + 8 / 9 * ((H9 < C10) * (H9 - C10) + (C10 < L9) * (C10 - L9) + 8 / 9 * ((H10 < C11) * (H10 - C11) + (C11 < L10) * (C11 - L10) + 8 / 9 * ((H11 < C12) * (H11 - C12) + (C12 < L11) * (C12 - L11) + 8 / 9 * ((H12 < C13) * (H12 - C13) + (C13 < L12) * (C13 - L12) + 8 / 9 * ((H13 < C14) * (H13 - C14) + (C14 < L13) * (C14 - L13) + 8 / 9 * ((H14 < C15) * (H14 - C15) + (C15 < L14) * (C15 - L14) + 8 / 9 * ((H15 < C16) * (H15 - C16) + (C16 < L15) * (C16 - L15) + 8 / 9 * ((H16 < C17) * (H16 - C17) + (C17 < L16) * (C17 - L16) + 8 / 9 * ((H17 < C18) * (H17 - C18) + (C18 < L17) * (C18 - L17) + 8 / 9 * ((H18 < C19) * (H18 - C19) + (C19 < L18) * (C19 - L18) + 8 / 9 * ((H19 < C20) * (H19 - C20) + (C20 < L19) * (C20 - L19) + 8 / 9 * ((H20 < C21) * (H20 - C21) + (C21 < L20) * (C21 - L20) + 8 / 9 * ((H21 < C22) * (H21 - C22) + (C22 < L21) * (C22 - L21) + 8 / 9 * ((H22 < C23) * (H22 - C23) + (C23 < L22) * (C23 - L22) + 8 / 9 * ((H23 < C24) * (H23 - C24) + (C24 < L23) * (C24 - L23) + 8 / 9 * ((H24 < C25) * (H24 - C25) + (C25 < L24) * (C25 - L24) + 8 / 9 * ((H25 < C26) * (H25 - C26) + (C26 < L25) * (C26 - L25) + 8 / 9 * ((H26 < C27) * (H26 - C27) + (C27 < L26) * (C27 - L26) + 8 / 9 * ((H27 < C28) * (H27 - C28) + (C28 < L27) * (C28 - L27) + 8 / 9 * ((H28 < C29) * (H28 - C29) + (C29 < L28) * (C29 - L28) + 8 / 9 * ((H29 < C30) * (H29 - C30) + (C30 < L29) * (C30 - L29) + 8 / 9 * ((H30 < C31) * (H30 - C31) + (C31 < L30) * (C31 - L30) + 8 / 9 * ((H31 < C32) * (H31 - C32) + (C32 < L31) * (C32 - L31) + 8 / 9 * ((H32 < C33) * (H32 - C33) + (C33 < L32) * (C33 - L32) + 8 / 9 * ((H33 < C34) * (H33 - C34) + (C34 < L33) * (C34 - L33) + 8 / 9 * ((H34 < C35) * (H34 - C35) + (C35 < L34) * (C35 - L34) + 8 / 9 * ((H35 < C36) * (H35 - C36) + (C36 < L35) * (C36 - L35) + 8 / 9 * ((H36 < C37) * (H36 - C37) + (C37 < L36) * (C37 - L36) + 8 / 9 * ((H37 < C38) * (H37 - C38) + (C38 < L37) * (C38 - L37) + 8 / 9 * ((H38 < C39) * (H38 - C39) + (C39 < L38) * (C39 - L38) + 8 / 9 * ((H39 < C40) * (H39 - C40) + (C40 < L39) * (C40 - L39) + 8 / 9 * ((H40 < C41) * (H40 - C41) + (C41 < L40) * (C41 - L40) + 8 / 9 * ((H41 < C42) * (H41 - C42) + (C42 < L41) * (C42 - L41) + 8 / 9 * ((H42 < C43) * (H42 - C43) + (C43 < L42) * (C43 - L42) + 8 / 9 * ((H43 < C44) * (H43 - C44) + (C44 < L43) * (C44 - L43) + 8 / 9 * ((H44 < C45) * (H44 - C45) + (C45 < L44) * (C45 - L44) + 8 / 9 * ((H45 < C46) * (H45 - C46) + (C46 < L45) * (C46 - L45) + 8 / 9 * ((H46 < C47) * (H46 - C47) + (C47 < L46) * (C47 - L46) + 8 / 9 * ((H47 < C48) * (H47 - C48) + (C48 < L47) * (C48 - L47) + 8 / 9 * ((H48 < C49) * (H48 - C49) + (C49 < L48) * (C49 - L48) + 8 / 9 * ((H49 < C50) * (H49 - C50) + (C50 < L49) * (C50 - L49) + 8 / 9 * ((H50 < C51) * (H50 - C51) + (C51 < L50) * (C51 - L50) + 8 / 9 * ((H51 < C52) * (H51 - C52) + (C52 < L51) * (C52 - L51) + 8 / 9 * ((H52 < C53) * (H52 - C53) + (C53 < L52) * (C53 - L52) + 8 / 9 * ((H53 < C54) * (H53 - C54) + (C54 < L53) * (C54 - L53) + 8 / 9 * ((H54 < C55) * (H54 - C55) + (C55 < L54) * (C55 - L54) + 8 / 9 * ((H55 < C56) * (H55 - C56) + (C56 < L55) * (C56 - L55) + 8 / 9 * ((H56 < C57) * (H56 - C57) + (C57 < L56) * (C57 - L56) + 8 / 9 * ((H57 < C58) * (H57 - C58) + (C58 < L57) * (C58 - L57) + 8 / 9 * ((H58 < C59) * (H58 - C59) + (C59 < L58) * (C59 - L58))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

This could be Plotted as a Custom Indicator as follows:

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

Here's an Exponential version to round things out:

9-Period Exponential Moving Average of True Range:

XAVGH9 - XAVGL9 + .200198266760174 * ((H < C1) * (H - C1) + (C1 < L) * (C1 - L) + .8 * ((H1 < C2) * (H1 - C2) + (C2 < L1) * (C2 - L1) + .8 * ((H2 < C3) * (H2 - C3) + (C3 < L2) * (C3 - L2) + .8 * ((H3 < C4) * (H3 - C4) + (C4 < L3) * (C4 - L3) + .8 * ((H4 < C5) * (H4 - C5) + (C5 < L4) * (C5 - L4) + .8 * ((H5 < C6) * (H5 - C6) + (C6 < L5) * (C6 - L5) + .8 * ((H6 < C7) * (H6 - C7) + (C7 < L6) * (C7 - L6) + .8 * ((H7 < C8) * (H7 - C8) + (C8 < L7) * (C8 - L7) + .8 * ((H8 < C9) * (H8 - C9) + (C9 < L8) * (C9 - L8) + .8 * ((H9 < C10) * (H9 - C10) + (C10 < L9) * (C10 - L9) + .8 * ((H10 < C11) * (H10 - C11) + (C11 < L10) * (C11 - L10) + .8 * ((H11 < C12) * (H11 - C12) + (C12 < L11) * (C12 - L11) + .8 * ((H12 < C13) * (H12 - C13) + (C13 < L12) * (C13 - L12) + .8 * ((H13 < C14) * (H13 - C14) + (C14 < L13) * (C14 - L13) + .8 * ((H14 < C15) * (H14 - C15) + (C15 < L14) * (C15 - L14) + .8 * ((H15 < C16) * (H15 - C16) + (C16 < L15) * (C16 - L15) + .8 * ((H16 < C17) * (H16 - C17) + (C17 < L16) * (C17 - L16) + .8 * ((H17 < C18) * (H17 - C18) + (C18 < L17) * (C18 - L17) + .8 * ((H18 < C19) * (H18 - C19) + (C19 < L18) * (C19 - L18) + .8 * ((H19 < C20) * (H19 - C20) + (C20 < L19) * (C20 - L19) + .8 * ((H20 < C21) * (H20 - C21) + (C21 < L20) * (C21 - L20) + .8 * ((H21 < C22) * (H21 - C22) + (C22 < L21) * (C22 - L21) + .8 * ((H22 < C23) * (H22 - C23) + (C23 < L22) * (C23 - L22) + .8 * ((H23 < C24) * (H23 - C24) + (C24 < L23) * (C24 - L23) + .8 * ((H24 < C25) * (H24 - C25) + (C25 < L24) * (C25 - L24) + .8 * ((H25 < C26) * (H25 - C26) + (C26 < L25) * (C26 - L25) + .8 * ((H26 < C27) * (H26 - C27) + (C27 < L26) * (C27 - L26) + .8 * ((H27 < C28) * (H27 - C28) + (C28 < L27) * (C28 - L27) + .8 * ((H28 < C29) * (H28 - C29) + (C29 < L28) * (C29 - L28) + .8 * ((H29 < C30) * (H29 - C30) + (C30 < L29) * (C30 - L29) + .8 * ((H30 < C31) * (H30 - C31) + (C31 < L30) * (C31 - L30))))))))))))))))))))))))))))))))

This could be Plotted as a Custom Indicator as follows:

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

You may wish to review the following:

Plotting Custom Indicators with Examples
How to create a Personal Criteria Forumula (PCF)
PCF Formula Descriptions
Cascades of Moving Averages
Handy PCF example formulas to help you learn the syntax of PCFs!

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
hawesdj
Posted : Thursday, October 23, 2008 11:00:35 AM
Registered User
Joined: 9/9/2008
Posts: 10
Bruce if I wanted to make a scan of stocks to make sure that theyre trading in at least a 1 to 2 point range based off of the last 9 days, would I use the code you have written for the ATR mov avg...or the longer code below?
Thanks,
Josh
Bruce_L
Posted : Thursday, October 23, 2008 11:14:16 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
hawesdj,
If you want to calculate an Average True Range using just 10-Days of data (you need the Close of the 10th day back for the calculations), you would use the 9-Period Simple Moving Average of True Range. For example:

9-Period Simple Moving Average of True Range at least $1:

(AVGH9 - AVGL9) / 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)) / 18 >= 1

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
hawesdj
Posted : Thursday, October 23, 2008 11:19:10 AM
Registered User
Joined: 9/9/2008
Posts: 10
Random question...when I bring up the data of a day on the chart...how do I display the %k number, it seems the stochastic calculation is the %D
Bruce_L
Posted : Thursday, October 23, 2008 11:23:49 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
hawesdj,
Yes, it reports the SD. Create the Stochastic with either the SK or SD Period set to 1 and then create the SD by adding a Moving Average Child Indicator to the Stochastic. This will give you both the SK (from the Stochastic) and the SD (from the Moving Average).

Understanding Stochastics

-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.