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 |

Need help writing a PCF for r-squared Topic Rating:
Previous Topic · Next Topic Watch this topic · Print this topic ·
gsn
Posted : Saturday, August 20, 2005 5:21:00 PM
Registered User
Joined: 11/13/2004
Posts: 121

Please see the R-Squared (R^2) topic for improved syntax in TC2000 v17+.

I use an Excel function, RSQ, for r-squared. R-squared measures how closely prices follow a Linear Regression Trendline, according to p. 282 of Steven Achelis' "Technical Analysis from A to Z." It shows the strength of a trend -- the more closely prices move in a linear relationship with the passing of time, the stronger the trend.

R-squared is also available in another stock analysis program and I would love it if it were available in Tc2005 so I could discontinue my other subscription :)

Earlier this year, folks who are much smarter than me in the Yahoo Auxiliary 2000 group were kind enough to try and help me fashion a 250-day r-squared pcf. But the results have never mirrored the result I get with Excel or this other product -- both get the same result whereas the PCF I am listing below does not. I think I frustrated people a little because I am not mathematically-inclined so this is above my head and I only know that the results aren't the same. As an example, as of 8/19 closing prices for NRPH, Excel has the 250-day r-squared result as 0.904 and so does Metastock but this PCF records 86.25. Have I done something wrong below? Is there a mistake in it? Does anyone out there use r-squared with TC2005 who can share their formula?

Here is the PCF I have been working on:

100 * (((250 - 1) / 2) * AVGC250 - (1 * C1 + 2 * C2 + 3 * C3 + 4 *
C4 + 5 * C5 + 6 * C6 + 7 * C7 + 8 * C8 + 9 * C9 + 10 * C10 + 11 *
C11 + 12 * C12 + 13 * C13 + 14 * C14 + 15 * C15 + 16 * C16 + 17 *
C17 + 18 * C18 + 19 * C19 + 20 * C20 + 21 * C21 + 22 * C22 + 23 *
C23 + 24 * C24 + 25 * C25 + 26 * C26 + 27 * C27 + 28 * C28 + 29 *
C29 + 30 * C30 + 31 * C31 + 32 * C32 + 33 * C33 + 34 * C34 + 35 *
C35 + 36 * C36 + 37 * C37 + 38 * C38 + 39 * C39 + 40 * C40 + 41 *
C41 + 42 * C42 + 43 * C43 + 44 * C44 + 45 * C45 + 46 * C46 + 47 *
C47 + 48 * C48 + 49 * C49 + 50 * C50 + 51 * C51 + 52 * C52 + 53 *
C53 + 54 * C54 + 55 * C55 + 56 * C56 + 57 * C57 + 58 * C58 + 59 *
C59 + 60 * C60 + 61 * C61 + 62 * C62 + 63 * C63 + 64 * C64 + 65 *
C65 + 66 * C66 + 67 * C67 + 68 * C68 + 69 * C69 + 70 * C70 + 71 *
C71 + 72 * C72 + 73 * C73 + 74 * C74 + 75 * C75 + 76 * C76 + 77 *
C77 + 78 * C78 + 79 * C79 + 80 * C80 + 81 * C81 + 82 * C82 + 83 *
C83 + 84 * C84 + 85 * C85 + 86 * C86 + 87 * C87 + 88 * C88 + 89 *
C89 + 90 * C90 + 91 * C91 + 92 * C92 + 93 * C93 + 94 * C94 + 95 *
C95 + 96 * C96 + 97 * C97 + 98 * C98 + 99 * C99 + 100 * C100 + 101 *
C101 + 102 * C102 + 103 * C103 + 104 * C104 + 105 * C105 + 106 *
C106 + 107 * C107 + 108 * C108 + 109 * C109 + 110 * C110 + 111 *
C111 + 112 * C112 + 113 * C113 + 114 * C114 + 115 * C115 + 116 *
C116 + 117 * C117 + 118 * C118 + 119 * C119 + 120 * C120 + 121 *
C121 + 122 * C122 + 123 * C123 + 124 * C124 + 125 * C125 + 126 *
C126 + 127 * C127 + 128 * C128 + 129 * C129 + 130 * C130 + 131 *
C131 + 132 * C132 + 133 * C133 + 134 * C134 + 135 * C135 + 136 *
C136 + 137 * C137 + 138 * C138 + 139 * C139 + 140 * C140 + 141 *
C141 + 142 * C142 + 143 * C143 + 144 * C144 + 145 * C145 + 146 *
C146 + 147 * C147 + 148 * C148 + 149 * C149 + 150 * C150 + 151 *
C151 + 152 * C152 + 153 * C153 + 154 * C154 + 155 * C155 + 156 *
C156 + 157 * C157 + 158 * C158 + 159 * C159 + 160 * C160 + 161 *
C161 + 162 * C162 + 163 * C163 + 164 * C164 + 165 * C165 + 166 *
C166 + 167 * C167 + 168 * C168 + 169 * C169 + 170 * C170 + 171 *
C171 + 172 * C172 + 173 * C173 + 174 * C174 + 175 * C175 + 176 *
C176 + 177 * C177 + 178 * C178 + 179 * C179 + 180 * C180 + 181 *
C181 + 182 * C182 + 183 * C183 + 184 * C184 + 185 * C185 + 186 *
C186 + 187 * C187 + 188 * C188 + 189 * C189 + 190 * C190 + 191 *
C191 + 192 * C192 + 193 * C193 + 194 * C194 + 195 * C195 + 196 *
C196 + 197 * C197 + 198 * C198 + 199 * C199 + 200 * C200 + 201 *
C201 + 202 * C202 + 203 * C203 + 204 * C204 + 205 * C205 + 206 *
C206 + 207 * C207 + 208 * C208 + 209 * C209 + 210 * C210 + 211 *
C211 + 212 * C212 + 213 * C213 + 214 * C214 + 215 * C215 + 216 *
C216 + 217 * C217 + 218 * C218 + 219 * C219 + 220 * C220 + 221 *
C221 + 222 * C222 + 223 * C223 + 224 * C224 + 225 * C225 + 226 *
C226 + 227 * C227 + 228 * C228 + 229 * C229 + 230 * C230 + 231 *
C231 + 232 * C232 + 233 * C233 + 234 * C234 + 235 * C235 + 236 *
C236 + 237 * C237 + 238 * C238 + 239 * C239 + 240 * C240 + 241 *
C241 + 242 * C242 + 243 * C243 + 244 * C244 + 245 * C245 + 246 *
C246 + 247 * C247 + 248 * C248 + 249 * C249) / 250) /
SQR(((250 * 250 - 1) / 12) * ((C0 * C0 + C1 * C1 + C2 * C2 + C3 * C3 + C4
* C4 + C5 * C5 + C6 * C6 + C7 * C7 + C8 * C8 + C9 * C9 + C10 * C10 + C11 * C11
+ C12 * C12 + C13 * C13 + C14 * C14 + C15 * C15 + C16 * C16 + C17 * C17 + C18 *
C18 + C19 * C19 + C20 * C20 + C21 * C1 + C22 * C22 + C23 * C23 + C24 * C24 + C25
* C25 + C26 * C26 + C27 * C27 + C28 * C28 + C29 * C29 + C30 * C30 + C31 * C31 +
C32 * C32 + C33 * C33 + C34 * C34 + C35 * C35 + C36 * C36 + C37 * C37 + C38 * C38
+ C39 * C39 + C40 * C40 + C41 * C41 + C42 * C42 + C43 * C43 + C44 * C44 + C45 * C45 + C46 * C46 + C47 * C47
+ C48 * C48 + C49 * C49 + C50 * C50 + C51 * C51 + C52 * C52
+ C53 * C53 + C54 * C54 + C55 * C55 + C56 * C56 + C57 * C57 + C58 * C58 + C59 * C59 + C60 * C60 + C61 * C61 + C62 * C62 + C63 * C63 + C64 * C64 + C65 * C65 + C66
* C66 + C67 * C67 + C68 * C68 + C69 * C69 + C70 * C70 + C71 * C71 + C72 * C72 +
C73 * C73 + C74 * C74 + C75 * C75 + C76 * C76 + C77 * C77 + C78 * C78 + C79 * C79
+ C80 * C80 + C81 * C81 + C82 * C82 + C83 * C83 + C84 * C84 + C85 * C85 + C86 * C86 + C87 * C87 + C88 * C88 + C89 * C89 + C90 * C90 + C91 * C91 + C92 * C92 + C93
* C93 + C94 * C94 + C95 * C95 + C96 * C96 + C97 * C97 + C98 * C98 + C99 * C99 +
C100 * C100 + C101 * C101 + C102 * C102 + C103 * C103 + C104 * C104 + C105 * C105 +
C106 * C106 + C107 * C107 + C108 * C108 + C109 * C109 + C110 * C110 + C111 * C111 +
C112 * C112 + C113 * C113 + C114 * C114 + C115 * C115 + C116 * C116 + C117 * C117 +
C118 * C118 + C119 * C119 + C120 * C120 + C121 * C121 + C122 * C122 + C123 * C123 +
C124 * C124 + C125 * C125 + C126 * C126 + C127 * C127 + C128 * C128 + C129 * C129 +
C130 * C130 + C131 * C131 + C132 * C132 + C133 * C133 + C134 * C134 + C135 * C135 +
C136 * C136 + C137 * C137 + C138 * C138 + C139 * C139 + C140 * C140 + C141 * C141 +
C142 * C142 + C143 * C143 + C144 * C144 + C145 * C145 + C146 * C146 + C147 * C147 +
C148 * C148 + C149 * C149 + C150 * C150 + C151 * C151 + C152 * C152 + C153 * C153 +
C154 * C154 + C155 * C155 + C156 * C156 + C157 * C157 + C158 * C158 + C159 * C159 +
C160 * C160 + C161 * C161 + C162 * C162 + C163 * C163 + C164 * C164 + C165 * C165 +
C166 * C166 + C167 * C167 + C168 * C168 + C169 * C169 + C170 * C170 + C171 * C171 +
C172 * C172 + C173 * C173 + C174 * C174 + C175 * C175 + C176 * C176 + C177 * C177 +
C178 * C178 + C179 * C179 + C180 * C180 + C181 * C181 + C182 * C182 + C183 * C183 +
C184 * C184 + C185 * C185 + C186 * C186 + C187 * C187 + C188 * C188 + C189 * C189 +
C190 * C190 + C191 * C191 + C192 * C192 + C193 * C193 + C194 * C194 + C195 * C195 +
C196 * C196 + C197 * C197 + C198 * C198 + C199 * C199 + C200 * C200 + C201 * C201 +
C202 * C102 + C203 * C203 + C204 * C204 + C205 * C205 + C206 * C206 + C207 * C207 +
C208 * C208 + C209 * C209 + C210 * C210 + C211 * C211 + C212 * C212 + C213 * C213 +
C214 * C214 + C215 * C215 + C216 * C216 + C217 * C217 + C218 * C218 + C219 * C219 +
C220 * C220 + C221 * C221 + C222 * C222 + C223 * C223 + C224 * C224 + C225 * C225 +
C226 * C226 + C227 * C227 + C228 * C228 + C229 * C229 + C230 * C230 + C231 * C231 +
C232 * C232 + C233 * C233 + C234 * C234 + C235 * C235 * C236 * C236 + C237 * C237 +
C238 * C238 + C239 * C239 + C240 * C240 + C241 * C241 + C242 * C242 + C243 * C243 +
C244 * C244 + C245 * C255 + C246 * C246 + C247 * C247 + C248 * C248 + C249 * C249 ) / 250 - AVGC250 ^2))


 

Bruce_L
Posted : Saturday, August 20, 2005 9:33:11 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The following seems to match Excel (you can multiply it by 100 if you want to see as many digits as with your original formula):

((((250 - 1) / 2) * AVGC250 - (C1 +2*C2 +3*C3 +4*C4 +5*C5 +6*C6 +7*C7 +8*C8 +9*C9 +10*C10 +11*C11 +12*C12 +13*C13 +14*C14 +15*C15 +16*C16 +17*C17 +18*C18 +19*C19 +20*C20 +21*C21 +22*C22 +23*C23 +24*C24 +25*C25 +26*C26 +27*C27 +28*C28 +29*C29 +30*C30 +31*C31 +32*C32 +33*C33 +34*C34 +35*C35 +36*C36 +37*C37 +38*C38 +39*C39 +40*C40 +41*C41 +42*C42 +43*C43 +44*C44 +45*C45 +46*C46 +47*C47 +48*C48 +49*C49 +50*C50 +51*C51 +52*C52 +53*C53 +54*C54 +55*C55 +56*C56 +57*C57 +58*C58 +59*C59 +60*C60 +61*C61 +62*C62 +63*C63 +64*C64 +65*C65 +66*C66 +67*C67 +68*C68 +69*C69 +70*C70 +71*C71 +72*C72 +73*C73 +74*C74 +75*C75 +76*C76 +77*C77 +78*C78 +79*C79 +80*C80 +81*C81 +82*C82 +83*C83 +84*C84 +85*C85 +86*C86 +87*C87 +88*C88 +89*C89 +90*C90 +91*C91 +92*C92 +93*C93 +94*C94 +95*C95 +96*C96 +97*C97 +98*C98 +99*C99 +100*C100 +101*C101 +102*C102 +103*C103 +104*C104 +105*C105 +106*C106 +107*C107 +108*C108 +109*C109 +110*C110 +111*C111 +112*C112 +113*C113 +114*C114 +115*C115 +116*C116 +117*C117 +118*C118 +119*C119 +120*C120 +121*C121 +122*C122 +123*C123 +124*C124 +125*C125 +126*C126 +127*C127 +128*C128 +129*C129 +130*C130 +131*C131 +132*C132 +133*C133 +134*C134 +135*C135 +136*C136 +137*C137 +138*C138 +139*C139 +140*C140 +141*C141 +142*C142 +143*C143 +144*C144 +145*C145 +146*C146 +147*C147 +148*C148 +149*C149 +150*C150 +151*C151 +152*C152 +153*C153 +154*C154 +155*C155 +156*C156 +157*C157 +158*C158 +159*C159 +160*C160 +161*C161 +162*C162 +163*C163 +164*C164 +165*C165 +166*C166 +167*C167 +168*C168 +169*C169 +170*C170 +171*C171 +172*C172 +173*C173 +174*C174 +175*C175 +176*C176 +177*C177 +178*C178 +179*C179 +180*C180 +181*C181 +182*C182 +183*C183 +184*C184 +185*C185 +186*C186 +187*C187 +188*C188 +189*C189 +190*C190 +191*C191 +192*C192 +193*C193 +194*C194 +195*C195 +196*C196 +197*C197 +198*C198 +199*C199 +200*C200 +201*C201 +202*C202 +203*C203 +204*C204 +205*C205 +206*C206 +207*C207 +208*C208 +209*C209 +210*C210 +211*C211 +212*C212 +213*C213 +214*C214 +215*C215 +216*C216 +217*C217 +218*C218 +219*C219 +220*C220 +221*C221 +222*C222 +223*C223 +224*C224 +225*C225 +226*C226 +227*C227 +228*C228 +229*C229 +230*C230 +231*C231 +232*C232 +233*C233 +234*C234 +235*C235 +236*C236 +237*C237 +238*C238 +239*C239 +240*C240 +241*C241 +242*C242 +243*C243 +244*C244 +245*C245 +246*C246 +247*C247 +248*C248 +249*C249) / 250) / SQR(((250^2 - 1) / 12) * ((C^2 +C1^2 +C2^2 +C3^2 +C4^2 +C5^2 +C6^2 +C7^2 +C8^2 +C9^2 +C10^2 +C11^2 +C12^2 +C13^2 +C14^2 +C15^2 +C16^2 +C17^2 +C18^2 +C19^2 +C20^2 +C21^2 +C22^2 +C23^2 +C24^2 +C25^2 +C26^2 +C27^2 +C28^2 +C29^2 +C30^2 +C31^2 +C32^2 +C33^2 +C34^2 +C35^2 +C36^2 +C37^2 +C38^2 +C39^2 +C40^2 +C41^2 +C42^2 +C43^2 +C44^2 +C45^2 +C46^2 +C47^2 +C48^2 +C49^2 +C50^2 +C51^2 +C52^2 +C53^2 +C54^2 +C55^2 +C56^2 +C57^2 +C58^2 +C59^2 +C60^2 +C61^2 +C62^2 +C63^2 +C64^2 +C65^2 +C66^2 +C67^2 +C68^2 +C69^2 +C70^2 +C71^2 +C72^2 +C73^2 +C74^2 +C75^2 +C76^2 +C77^2 +C78^2 +C79^2 +C80^2 +C81^2 +C82^2 +C83^2 +C84^2 +C85^2 +C86^2 +C87^2 +C88^2 +C89^2 +C90^2 +C91^2 +C92^2 +C93^2 +C94^2 +C95^2 +C96^2 +C97^2 +C98^2 +C99^2 +C100^2 +C101^2 +C102^2 +C103^2 +C104^2 +C105^2 +C106^2 +C107^2 +C108^2 +C109^2 +C110^2 +C111^2 +C112^2 +C113^2 +C114^2 +C115^2 +C116^2 +C117^2 +C118^2 +C119^2 +C120^2 +C121^2 +C122^2 +C123^2 +C124^2 +C125^2 +C126^2 +C127^2 +C128^2 +C129^2 +C130^2 +C131^2 +C132^2 +C133^2 +C134^2 +C135^2 +C136^2 +C137^2 +C138^2 +C139^2 +C140^2 +C141^2 +C142^2 +C143^2 +C144^2 +C145^2 +C146^2 +C147^2 +C148^2 +C149^2 +C150^2 +C151^2 +C152^2 +C153^2 +C154^2 +C155^2 +C156^2 +C157^2 +C158^2 +C159^2 +C160^2 +C161^2 +C162^2 +C163^2 +C164^2 +C165^2 +C166^2 +C167^2 +C168^2 +C169^2 +C170^2 +C171^2 +C172^2 +C173^2 +C174^2 +C175^2 +C176^2 +C177^2 +C178^2 +C179^2 +C180^2 +C181^2 +C182^2 +C183^2 +C184^2 +C185^2 +C186^2 +C187^2 +C188^2 +C189^2 +C190^2 +C191^2 +C192^2 +C193^2 +C194^2 +C195^2 +C196^2 +C197^2 +C198^2 +C199^2 +C200^2 +C201^2 +C202^2 +C203^2 +C204^2 +C205^2 +C206^2 +C207^2 +C208^2 +C209^2 +C210^2 +C211^2 +C212^2 +C213^2 +C214^2 +C215^2 +C216^2 +C217^2 +C218^2 +C219^2 +C220^2 +C221^2 +C222^2 +C223^2 +C224^2 +C225^2 +C226^2 +C227^2 +C228^2 +C229^2 +C230^2 +C231^2 +C232^2 +C233^2 +C234^2 +C235^2 +C236^2 +C237^2 +C238^2 +C239^2 +C240^2 +C241^2 +C242^2 +C243^2 +C244^2 +C245^2 +C246^2 +C247^2 +C248^2 +C249^2 ) / 250 - AVGC250^2)))^2

If you are using something similar to RSQ(A1:A250,B1:B250) in Excel, where A1:A250 is a range of prices, make sure B1:B250 is a range of consecutively numbered trading days. If B1:B250 is a range of dates, Excel will produce incorrect results because of weekends and market holidays.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
bustermu
Posted : Sunday, August 21, 2005 6:52:09 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
Bruce,

Your response to questions involving long PCF's is so fast, I am curious as to how you do it.

For example, suppose we wanted a PCF for the form:

0*C0+1*C1+2*C2+...+(P-1)*C(P-1)

when P = 250.

I would:

1) copy, paste, and change digits until obtaining:

0*C0+1*C1+...9*C9

2) add copies of the above many times

3) place 1's in front of each digit of the second copy, place 2's in front of each digit of the third copy, etc., etc.

I suspect that you have a program that is something like:

Write the expression for the sum of

N*CN

for N = 0 to 249.

Am I correct, or are you just that fast?

Thanks,
Jim Murphy
Bruce_L
Posted : Sunday, August 21, 2005 8:28:46 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The quick answer is I use a spreadsheet, but your example is simple enough I can provide more details. Here's row 1 the quick and dirty way:

A1=0
B1=A1&"*C"&A1

Row 2 is similar, but adds to the results of row 1:

A2=A1+1
B2=B1&" +"&A2&"*C"&A2

Rows 3-250 are just incremented copies of row 2 (which happens automatically using copy and paste). B250 is the requested formula.

In actual practice, it is usually a bit more complicated than this. Partly this is due to more complex formulas, but it is mostly the result of wanting the ability to reuse the spreadsheet using different parameters several months later without needing to redo anything or even remember how I did it the first time.

Worden Brothers only provides training for our own products, so I can't actually give much detail or instruction beyond what I've already written, but an Internet search should come up with numerous resources for learning how to write spreadsheets.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
jynkin
Posted : Sunday, August 21, 2005 4:46:51 PM
Registered User
Joined: 10/7/2004
Posts: 286
Bruce_L

To change the above 250 day R-Squared PCF above to say a 100 day R-Squared PCF, I just remove all number sets with day numbers over 100 and change any of the 250 numbers to 100?

Thanks,
jynkin
Bruce_L
Posted : Sunday, August 21, 2005 5:20:10 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You are very close. Remove everything with days ago numbers over 99 and change all instances of 250 to 100.

((((100 - 1) / 2) * AVGC100 - (C1 +2*C2 +3*C3 +4*C4 +5*C5 +6*C6 +7*C7 +8*C8 +9*C9 +10*C10 +11*C11 +12*C12 +13*C13 +14*C14 +15*C15 +16*C16 +17*C17 +18*C18 +19*C19 +20*C20 +21*C21 +22*C22 +23*C23 +24*C24 +25*C25 +26*C26 +27*C27 +28*C28 +29*C29 +30*C30 +31*C31 +32*C32 +33*C33 +34*C34 +35*C35 +36*C36 +37*C37 +38*C38 +39*C39 +40*C40 +41*C41 +42*C42 +43*C43 +44*C44 +45*C45 +46*C46 +47*C47 +48*C48 +49*C49 +50*C50 +51*C51 +52*C52 +53*C53 +54*C54 +55*C55 +56*C56 +57*C57 +58*C58 +59*C59 +60*C60 +61*C61 +62*C62 +63*C63 +64*C64 +65*C65 +66*C66 +67*C67 +68*C68 +69*C69 +70*C70 +71*C71 +72*C72 +73*C73 +74*C74 +75*C75 +76*C76 +77*C77 +78*C78 +79*C79 +80*C80 +81*C81 +82*C82 +83*C83 +84*C84 +85*C85 +86*C86 +87*C87 +88*C88 +89*C89 +90*C90 +91*C91 +92*C92 +93*C93 +94*C94 +95*C95 +96*C96 +97*C97 +98*C98 +99*C99) / 100) / SQR(((100^2 - 1) / 12) * ((C^2 +C1^2 +C2^2 +C3^2 +C4^2 +C5^2 +C6^2 +C7^2 +C8^2 +C9^2 +C10^2 +C11^2 +C12^2 +C13^2 +C14^2 +C15^2 +C16^2 +C17^2 +C18^2 +C19^2 +C20^2 +C21^2 +C22^2 +C23^2 +C24^2 +C25^2 +C26^2 +C27^2 +C28^2 +C29^2 +C30^2 +C31^2 +C32^2 +C33^2 +C34^2 +C35^2 +C36^2 +C37^2 +C38^2 +C39^2 +C40^2 +C41^2 +C42^2 +C43^2 +C44^2 +C45^2 +C46^2 +C47^2 +C48^2 +C49^2 +C50^2 +C51^2 +C52^2 +C53^2 +C54^2 +C55^2 +C56^2 +C57^2 +C58^2 +C59^2 +C60^2 +C61^2 +C62^2 +C63^2 +C64^2 +C65^2 +C66^2 +C67^2 +C68^2 +C69^2 +C70^2 +C71^2 +C72^2 +C73^2 +C74^2 +C75^2 +C76^2 +C77^2 +C78^2 +C79^2 +C80^2 +C81^2 +C82^2 +C83^2 +C84^2 +C85^2 +C86^2 +C87^2 +C88^2 +C89^2 +C90^2 +C91^2 +C92^2 +C93^2 +C94^2 +C95^2 +C96^2 +C97^2 +C98^2 +C99^2) / 100 - AVGC100^2)))^2

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
jynkin
Posted : Sunday, August 21, 2005 8:44:09 PM
Registered User
Joined: 10/7/2004
Posts: 286
thanks,...this web-based discussion channel is a great asset to TCNET and your help with these complex PCF's is much appreciated.

jynkin
gsn
Posted : Monday, August 22, 2005 12:41:39 PM
Registered User
Joined: 11/13/2004
Posts: 121
Bruce, I want to thank you so much. It works great and gives me the same result as in Excel and other programs. Your prompt reply is much appreciated -- great service is one of the reasons I value TC2005 so much.
jynkin
Posted : Tuesday, December 6, 2005 12:12:40 PM
Registered User
Joined: 10/7/2004
Posts: 286
Is the following formula for 35 day Rquared correct? In particular I'm not sure about the divide by 12 part in the middle area. It seems that all my Rsquared formulas have this divide by 12 section, but I'm not sure if it shouldn't be the n period of the formula. i.e. /35 ??

Thanks,
jynkin

(((((35 - 1) / 2) * AVGC35 - (C1 + 2 * C2 + 3 * C3 + 4 * C4 + 5 * C5 + 6 * C6 + 7 * C7 + 8 * C8 + 9 * C9 + 10 * C10 + 11 * C11 + 12 * C12 + 13 * C13 + 14 * C14 + 15 * C15 + 16 * C16 + 17 * C17 + 18 * C18 + 19 * C19 + 20 * C20 + 21 * C21 + 22 * C22 + 23 * C23 + 24 * C24 + 25 * C25 + 26 * C26 + 27 * C27 + 28 * C28 + 29 * C29 + 30 * C30 + 31 * C31 + 32 * C32 + 33 * C33 + 34 * C34) / 35) / SQR(((35 * 35 - 1) / 12) * ((C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 + C20 ^ 2 + C21 ^ 2 + C22 ^ 2 + C23 ^ 2 + C24 ^ 2 + C25 ^ 2 + C26 ^ 2 + C27 ^ 2 + C28 ^ 2 + C29 ^ 2 + C30 ^ 2 + C31 ^ 2 + C32 ^ 2 + C33 ^ 2 + C34 ^ 2) / 35 - AVGC35 ^ 2))) ^ 2)
Bruce_L
Posted : Tuesday, December 6, 2005 3:04:53 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
It looks correct to me. The "/ 12" should appear in the formula whatever the period.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Stmjd74
Posted : Thursday, December 22, 2005 5:22:01 AM
Registered User
Joined: 12/18/2004
Posts: 180
Bruce, what about a PCF for Standard Error? It can be used with R-Squared to indicate the volatility of prices around the LR Trendline by measuring how closely they congregate around it. High values = high volatility, low values = low volatility, high R-Squared = srong trend, low R-Squared = weak trend, etc. Falling R-Squared with rising Standard Error can be used to spot trend changes, etc. Could you give us a PCF for, say, a 14-day Standard Error?

Thanks.
Stmjd74
Posted : Thursday, December 22, 2005 5:37:13 AM
Registered User
Joined: 12/18/2004
Posts: 180
...Or would this involve calculating the LR Trendline 14 times? If it is the same as StdDev of a moving average, this might not be practical, especially for longer periods! Unless you know of a work-around, or possible custom indicator solution.
bustermu
Posted : Thursday, December 22, 2005 10:03:59 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
Stmjd74,

What you are calling "Standard Error" I believe is rms of the LR curve fit error (LRrms). If so, A PCF for LRrms when the Period is 20 is:

SQR(((C^2+C1^2+C2^2+C3^2+C4^2+C5^2
+C6^2+C7^2+C8^2+C9^2+C10^2
+C11^2+C12^2+C13^2+C14^2+C15^2
+C16^2+C17^2+C18^2+C19^2)/20
-AVGC20^2)
-12*(((0*C0+1*C1+2*C2+3*C3+4*C4+5*C5
+6*C6+7*C7+8*C8+9*C9+10*C10
+11*C11+12*C12+13*C13+14*C14+15*C15
+16*C16+17*C17+18*C18+19*C19)/20
-(20-1)*AVGC20/2)^2)/(20^2-1))

The Period 20 is left intact so that its value can be changed if desired.

Thanks,
Jim Murphy
Stmjd74
Posted : Thursday, December 22, 2005 10:27:09 AM
Registered User
Joined: 12/18/2004
Posts: 180
bustermu;

Yes. That appears to be what I'm looking for. The material I'm refering to simply calls it Standar Error. The example was for a 14-day period. I changed the formula you provided to a 14-day period and the shape of the indicator matches the example. Not many values are given in the example, but the ones that are given also seem to match.

Thanks.
bustermu
Posted : Thursday, December 22, 2005 12:58:00 PM
Registered User
Joined: 1/1/2005
Posts: 2,645
It may be of some interest to know how R-squared (R^2) and LRrms are related. Let StdDev be the Standard Deviation of the Close over the same period as that of R-squared and the LR.

Then,

LRrms = StdDev*SQR(1-R^2)

Thanks,
Jim Murphy
Stmjd74
Posted : Thursday, December 22, 2005 3:42:22 PM
Registered User
Joined: 12/18/2004
Posts: 180
Thanks for that explanation!
TheTechnician
Posted : Friday, February 10, 2012 4:55:14 PM
Registered User
Joined: 7/24/2008
Posts: 55
what is a good value for rsq?  10 20 30 50? how many values do you need to get a good correlation for intraday trading
Bruce_L
Posted : Friday, February 10, 2012 4:58:27 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The trainers can't give setting, interpretation or investment advice. While some might offer some advice here, I would try asking the question in the Stock and Market Talk forum where more traders are likely to see it and comment.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
gregche
Posted : Sunday, May 12, 2013 3:54:42 PM
Registered User
Joined: 5/17/2005
Posts: 8

Bruce

The definition of  'R-Squared' from Investopedia

A statistical measure that represents the percentage of a fund or security's movements that can be explained by movements in a benchmark index. For fixed-income securities, the benchmark is the T-bill. For equities, the benchmark is the S&P 500.

The formulas you provided don't take the benchmark into account does it? My question is how would we be able to compare this to the benchmark (or is this calculating it against the portfolio as the benchmark) or is this a different definition of R-Squared?

Bruce_L
Posted : Monday, May 13, 2013 9:37:16 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

The R-Squared being calcualted in this topic is being calculated against the linear regression line of the closing prices of that stock. It is not being calculated against another equity or against an index.

About the closest thing to what you want which can be found in TC2000 would be beta.

Beta - The coefficient which measures the volatility of a stock's returns relative to the market (S&P 500). It is based on a 36/60-month historical regression of the return on the stock onto the return on the S&P 500: Ri = a + (Rm) + e where Ri is the monthly total returns on the stock, a is the stock's Alpha, Rm is the monthly total returns on the market (S&P 500), and e is a random error term. A minimum of 12 monthly returns are required for this calculation. A beta of 1 means that the market and the stock move up or down together, at the same rate. That is, a 5% up or down move in the market should theoretically result in a 5% up or down move in the stock. A beta coefficient of 2 suggests that the stock will tend to fluctuate twice as much as the market. That is, if the market moves up 5%, then the stock should move up 10%. A beta coefficient of 0.5 indicates that the stock will move one-half as much as the market, either up or down. A negative beta indicates the stock tends to move in the opposite direction from the general market. That is, the stock price declines when the overall market is rising, or rises when the overall market is declining. Negative beta stocks are rare.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
gregche
Posted : Friday, May 31, 2013 7:05:19 AM
Registered User
Joined: 5/17/2005
Posts: 8

Thanks Bruce. 

Bruce_L
Posted : Friday, May 31, 2013 7:43:28 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.