Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 7/30/2007 Posts: 1,072
|
Hi Bruce,
In the past you've helped me with Linear Regression Slope and R-Squared, a Moving Linear Regression Line, and a "reversal indicator".
Today's linear regression request...
-
A PCF for percentage return per trading day (or bar).
The example below is for daily charts, but I use shorter timeframes. As with the other PCFs you've done in the past, it would be great to have these for:
-
5 bars
-
8 bars
-
13 bars
-
21 bars
-
34 bars
-
55 bars
I believe the percentage return per trading day (or bar) can be found by taking the slope and dividing by the closing price of the latest bar, and expressing it as a percentage. If my thinking is off (wouldn't be the first time) let me know.
For example, a stock with a latest closing price of $20 has been increasing an average of $0.10 per trading day (the slope of the regression line) over the last 63 days. The $0.10 slope divided by $20 is 0.005 or 0.5%. Half a percent is the average future return per trading day if the stock were purchased today for $20 and the historical trend continues. Expressing the slope as a percentage of the latest close allows for comparison with other securities.
Doable?
|
|
Registered User Joined: 7/30/2007 Posts: 1,072
|
.... and since I'll usually be running this intraday, can we make it the close of the latest completed bar, not the current bar which is "still in progress".
Thanks!
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
It is slightly more complicated than that because the same percent change near the end should produce a slightly larger net change than at the beginning.
5 bars:
100 * (EXP((2 * LOG(C ) + LOG(C1) - LOG(C3) - 2 * LOG(C4)) / 10) - 1)
8 bars:
100 * (EXP((3.5 * LOG(C ) + 2.5 * LOG(C1) + 1.5 * LOG(C2) + 0.5 * LOG(C3) - 0.5 * LOG(C4) - 1.5 * LOG(C5) - 2.5 * LOG(C6) - 3.5 * LOG(C7)) / 42) - 1)
13 bars:
100 * (EXP((6 * LOG(C ) + 5 * LOG(C1) + 4 * LOG(C2) + 3 * LOG(C3) + 2 * LOG(C4) + LOG(C5) - LOG(C7) - 2 * LOG(C8) - 3 * LOG(C9) - 4 * LOG(C10) - 5 * LOG(C11) - 6 * LOG(C12)) / 182) - 1)
21 bars:
100 * (EXP((10 * LOG(C ) + 9 * LOG(C1) + 8 * LOG(C2) + 7 * LOG(C3) + 6 * LOG(C4) + 5 * LOG(C5) + 4 * LOG(C6) + 3 * LOG(C7) + 2 * LOG(C8) + LOG(C9) - LOG(C11) - 2 * LOG(C12) - 3 * LOG(C13) - 4 * LOG(C14) - 5 * LOG(C15) - 6 * LOG(C16) - 7 * LOG(C17) - 8 * LOG(C18) - 9 * LOG(C19) - 10 * LOG(C20)) / 770) - 1)
34 bars:
100 * (EXP((16.5 * LOG(C ) + 15.5 * LOG(C1) + 14.5 * LOG(C2) + 13.5 * LOG(C3) + 12.5 * LOG(C4) + 11.5 * LOG(C5) + 10.5 * LOG(C6) + 9.5 * LOG(C7) + 8.5 * LOG(C8) + 7.5 * LOG(C9) + 6.5 * LOG(C10) + 5.5 * LOG(C11) + 4.5 * LOG(C12) + 3.5 * LOG(C13) + 2.5 * LOG(C14) + 1.5 * LOG(C15) + 0.5 * LOG(C16) - 0.5 * LOG(C17) - 1.5 * LOG(C18) - 2.5 * LOG(C19) - 3.5 * LOG(C20) - 4.5 * LOG(C21) - 5.5 * LOG(C22) - 6.5 * LOG(C23) - 7.5 * LOG(C24) - 8.5 * LOG(C25) - 9.5 * LOG(C26) - 10.5 * LOG(C27) - 11.5 * LOG(C28) - 12.5 * LOG(C29) - 13.5 * LOG(C30) - 14.5 * LOG(C31) - 15.5 * LOG(C32) - 16.5 * LOG(C33)) / 3272.5) - 1)
55 bars:
100 * (EXP((27 * LOG(C ) + 26 * LOG(C1) + 25 * LOG(C2) + 24 * LOG(C3) + 23 * LOG(C4) + 22 * LOG(C5) + 21 * LOG(C6) + 20 * LOG(C7) + 19 * LOG(C8) + 18 * LOG(C9) + 17 * LOG(C10) + 16 * LOG(C11) + 15 * LOG(C12) + 14 * LOG(C13) + 13 * LOG(C14) + 12 * LOG(C15) + 11 * LOG(C16) + 10 * LOG(C17) + 9 * LOG(C18) + 8 * LOG(C19) + 7 * LOG(C20) + 6 * LOG(C21) + 5 * LOG(C22) + 4 * LOG(C23) + 3 * LOG(C24) + 2 * LOG(C25) + LOG(C26) - LOG(C28) - 2 * LOG(C29) - 3 * LOG(C30) - 4 * LOG(C31) - 5 * LOG(C32) - 6 * LOG(C33) - 7 * LOG(C34) - 8 * LOG(C35) - 9 * LOG(C36) - 10 * LOG(C37) - 11 * LOG(C38) - 12 * LOG(C39) - 13 * LOG(C40) - 14 * LOG(C41) - 15 * LOG(C42) - 16 * LOG(C43) - 17 * LOG(C44) - 18 * LOG(C45) - 19 * LOG(C46) - 20 * LOG(C47) - 21 * LOG(C48) - 22 * LOG(C49) - 23 * LOG(C50) - 24 * LOG(C51) - 25 * LOG(C52) - 26 * LOG(C53) - 27 * LOG(C54)) / 13860) - 1)
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
QUOTE (Putt4Dough) .... and since I'll usually be running this intraday, can we make it the close of the latest completed bar, not the current bar which is "still in progress".
5 bars:
100 * (EXP((2 * LOG(C1 ) + LOG(C2) - LOG(C4) - 2 * LOG(C5)) / 10) - 1)
8 bars:
100 * (EXP((3.5 * LOG(C1 ) + 2.5 * LOG(C2) + 1.5 * LOG(C3) + 0.5 * LOG(C4) - 0.5 * LOG(C5) - 1.5 * LOG(C6) - 2.5 * LOG(C7) - 3.5 * LOG(C8)) / 42) - 1)
13 bars:
100 * (EXP((6 * LOG(C1 ) + 5 * LOG(C2) + 4 * LOG(C3) + 3 * LOG(C4) + 2 * LOG(C5) + LOG(C6) - LOG(C8) - 2 * LOG(C9) - 3 * LOG(C10) - 4 * LOG(C11) - 5 * LOG(C12) - 6 * LOG(C13)) / 182) - 1)
21 bars:
100 * (EXP((10 * LOG(C1 ) + 9 * LOG(C2) + 8 * LOG(C3) + 7 * LOG(C4) + 6 * LOG(C5) + 5 * LOG(C6) + 4 * LOG(C7) + 3 * LOG(C8) + 2 * LOG(C9) + LOG(C10) - LOG(C12) - 2 * LOG(C13) - 3 * LOG(C14) - 4 * LOG(C15) - 5 * LOG(C16) - 6 * LOG(C17) - 7 * LOG(C18) - 8 * LOG(C19) - 9 * LOG(C20) - 10 * LOG(C21)) / 770) - 1)
34 bars:
100 * (EXP((16.5 * LOG(C1 ) + 15.5 * LOG(C2) + 14.5 * LOG(C3) + 13.5 * LOG(C4) + 12.5 * LOG(C5) + 11.5 * LOG(C6) + 10.5 * LOG(C7) + 9.5 * LOG(C8) + 8.5 * LOG(C9) + 7.5 * LOG(C10) + 6.5 * LOG(C11) + 5.5 * LOG(C12) + 4.5 * LOG(C13) + 3.5 * LOG(C14) + 2.5 * LOG(C15) + 1.5 * LOG(C16) + 0.5 * LOG(C17) - 0.5 * LOG(C18) - 1.5 * LOG(C19) - 2.5 * LOG(C20) - 3.5 * LOG(C21) - 4.5 * LOG(C22) - 5.5 * LOG(C23) - 6.5 * LOG(C24) - 7.5 * LOG(C25) - 8.5 * LOG(C26) - 9.5 * LOG(C27) - 10.5 * LOG(C28) - 11.5 * LOG(C29) - 12.5 * LOG(C30) - 13.5 * LOG(C31) - 14.5 * LOG(C32) - 15.5 * LOG(C33) - 16.5 * LOG(C34)) / 3272.5) - 1)
55 bars:
100 * (EXP((27 * LOG(C1 ) + 26 * LOG(C2) + 25 * LOG(C3) + 24 * LOG(C4) + 23 * LOG(C5) + 22 * LOG(C6) + 21 * LOG(C7) + 20 * LOG(C8) + 19 * LOG(C9) + 18 * LOG(C10) + 17 * LOG(C11) + 16 * LOG(C12) + 15 * LOG(C13) + 14 * LOG(C14) + 13 * LOG(C15) + 12 * LOG(C16) + 11 * LOG(C17) + 10 * LOG(C18) + 9 * LOG(C19) + 8 * LOG(C20) + 7 * LOG(C21) + 6 * LOG(C22) + 5 * LOG(C23) + 4 * LOG(C24) + 3 * LOG(C25) + 2 * LOG(C26) + LOG(C27) - LOG(C29) - 2 * LOG(C30) - 3 * LOG(C31) - 4 * LOG(C32) - 5 * LOG(C33) - 6 * LOG(C34) - 7 * LOG(C35) - 8 * LOG(C36) - 9 * LOG(C37) - 10 * LOG(C38) - 11 * LOG(C39) - 12 * LOG(C40) - 13 * LOG(C41) - 14 * LOG(C42) - 15 * LOG(C43) - 16 * LOG(C44) - 17 * LOG(C45) - 18 * LOG(C46) - 19 * LOG(C47) - 20 * LOG(C48) - 21 * LOG(C49) - 22 * LOG(C50) - 23 * LOG(C51) - 24 * LOG(C52) - 25 * LOG(C53) - 26 * LOG(C54) - 27 * LOG(C55)) / 13860) - 1)
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 7/30/2007 Posts: 1,072
|
QUOTE (Bruce_L) It is slightly more complicated than that...
That's why I asked you Bruce, you're the MAN! Thank you sooo much.
|
|
Registered User Joined: 7/30/2007 Posts: 1,072
|
Happy Friday Bruce!
Sometimes I like looking at percentage return per bar, but other times I'd like to look at the absolute dollar amount return per bar. Like a fisherman, if the move is too small to cover commissions, risk, etc., I'll toss the fish back in the water. :)
Can you create PCFs for the above Fibs that calculate the return per bar in terms of dollars & cents?
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I think you we see significant similarity in the formulas.
5 bars:
(2 * C + C1 - C3 - 2 * C4) / 10
8 bars:
(3.5 * C + 2.5 * C1 + 1.5 * C2 + 0.5 * C3 - 0.5 * C4 - 1.5 * C5 - 2.5 * C6 - 3.5 * C7) / 42
13 bars:
(6 * C + 5 * C1 + 4 * C2 + 3 * C3 + 2 * C4 + C5 - C7 - 2 * C8 - 3 * C9 - 4 * C10 - 5 * C11 - 6 * C12) / 182
21 bars:
(10 * C + 9 * C1 + 8 * C2 + 7 * C3 + 6 * C4 + 5 * C5 + 4 * C6 + 3 * C7 + 2 * C8 + C9 - C11 - 2 * C12 - 3 * C13 - 4 * C14 - 5 * C15 - 6 * C16 - 7 * C17 - 8 * C18 - 9 * C19 - 10 * C20) / 770
34 bars:
(16.5 * C + 15.5 * C1 + 14.5 * C2 + 13.5 * C3 + 12.5 * C4 + 11.5 * C5 + 10.5 * C6 + 9.5 * C7 + 8.5 * C8 + 7.5 * C9 + 6.5 * C10 + 5.5 * C11 + 4.5 * C12 + 3.5 * C13 + 2.5 * C14 + 1.5 * C15 + 0.5 * C16 - 0.5 * C17 - 1.5 * C18 - 2.5 * C19 - 3.5 * C20 - 4.5 * C21 - 5.5 * C22 - 6.5 * C23 - 7.5 * C24 - 8.5 * C25 - 9.5 * C26 - 10.5 * C27 - 11.5 * C28 - 12.5 * C29 - 13.5 * C30 - 14.5 * C31 - 15.5 * C32 - 16.5 * C33) / 3272.5
55 bars: (27 * C + 26 * C1 + 25 * C2 + 24 * C3 + 23 * C4 + 22 * C5 + 21 * C6 + 20 * C7 + 19 * C8 + 18 * C9 + 17 * C10 + 16 * C11 + 15 * C12 + 14 * C13 + 13 * C14 + 12 * C15 + 11 * C16 + 10 * C17 + 9 * C18 + 8 * C19 + 7 * C20 + 6 * C21 + 5 * C22 + 4 * C23 + 3 * C24 + 2 * C25 + C26 - C28 - 2 * C29 - 3 * C30 - 4 * C31 - 5 * C32 - 6 * C33 - 7 * C34 - 8 * C35 - 9 * C36 - 10 * C37 - 11 * C38 - 12 * C39 - 13 * C40 - 14 * C41 - 15 * C42 - 16 * C43 - 17 * C44 - 18 * C45 - 19 * C46 - 20 * C47 - 21 * C48 - 22 * C49 - 23 * C50 - 24 * C51 - 25 * C52 - 26 * C53 - 27 * C54) / 13860
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 7/30/2007 Posts: 1,072
|
You're awesome, Bruce. Have a great weekend!!
|
|
Registered User Joined: 6/30/2017 Posts: 1,227
|
Happy Hump Day Bruce,
Thanks for the Linear Regression Slope and R-Squared PCFs the other day.
I dusted off an old request - figured there might be a simpler, better, faster way with the enhanced PCF syntax.
All the stuff we've been working on the last couple of weeks was for my intraday trading plan.
My linear regression toolbox is for my end-of-day swing trading plan.
I'm scanning for R-Squared levels that are "significant". If there are several candidates I look at slope. Other things being equal I'd rather take the trade where the slope is steeper rather than flatter.
Anyway, what's the 2018 version of the PCFs for the Percentage Return per Bar, and the Absolute Dollar Amount Return per Bar?
The faster the stock appreciates, the faster I can buy that yacht. ;)
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
The following would be the 45 period linear regression slope (it is already per bar).
6 * (FAVG(C,45) - AVG(C, 45)) / (45 - 1)
The following would be the 45 period annualized regression slope (getting rid of the 253 * in the annualized version converts it to per bar as well).
100 * (EXP(6 * (FAVG(LOG(C ), 45) - AVG(LOG(C ), 45)) / (45 - 1)) - 1)
You can change all instances of 45 in the formulas to change the period. And you can replace all instances of C with something else if you want the values to be based on something besides closing prices.
So changing all instances of C to C1 would get you the 1 bars ago version.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 6/30/2017 Posts: 1,227
|
Awesome, Bruce ... thanks! The first option I'll be getting for my yacht is Wi-Fi. And my own barista. ;)
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome. So I have started drinking a bit of coffee, but no barista for me so far. I just use an AeroPress. It is quick, cheap and I can make it as strong as I want.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 6/30/2017 Posts: 1,227
|
Actually, I hate coffee, but the barista is hot. :)
Kidding.
A buddy of mine just picked up an inexpensive Bodum coffee press. I'm looking at Bodum and AeroPress stuff. Hope to make a decision soon.
Coffee shops are nice, but the money I save on coffee I can use for trade commissions and my TC2000 subscription. Every bit helps when you're trying to be the first on your block to buy a yacht.
Just found this this morning. Two-and-a-half minute YouTube barista fantasy. LOL. I thought I was the only one. ;)
Baristas are the Ultimate Male Fantasy
One week until Michael and his crew hit Chicago. I'm sooooo excited. Can't wait.
|
|
Guest-1 |