Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Price difference divided by ATR20 Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
laertes1a
Posted : Tuesday, June 19, 2007 8:20:15 AM
Registered User
Joined: 3/11/2005
Posts: 12
I would like to write a pdf that subtracts today's close from 90 days ago's close--easy enough, then divides the difference by the Average True Range for the past 20 days. I would like to be able to sort my watchlist by this criteria.

Is there existing code for ATR already? I could use some help.

Thanks.
Bruce_L
Posted : Tuesday, June 19, 2007 8:35:06 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Please try the using the following Personal Criteria Formula as a Sort:

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

You may wish to review the following:

Please provide a description and PCF for calculating an ATR value to be used as a stop loss value
How to create a Personal Criteria Forumula (PCF)
Create your own stock rankings using WatchLists and Sort conditions
Customize the Information Displayed in the WatchList
Using EasyScan to find stocks that meet your own criteria
Average True Range (ATR)
Cascades of Moving Averages
Handy PCF example formulas to help you learn the syntax of PCFs!

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
laertes1a
Posted : Tuesday, June 19, 2007 8:54:20 AM
Registered User
Joined: 3/11/2005
Posts: 12
Dang! You're good.
Bruce_L
Posted : Tuesday, June 19, 2007 8:58:56 AM


Worden Trainer

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

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