You wrote: Brooke, thanks. I've tried to add the language to run for the last 10 days, but I can't seem to figure it out.
It's defeating me, too. I can't seem to get the right values for the 10 days back, when I add another for loop that subtracts "j" from "i." The long way to do it would be to create slopes for all 10 days, (b, bb, bbb, bbbb, etc.) But I'll keep trying the for loop for a while. Maybe Bob has some suggestions. If you did want to do it the long way, the next day back (-2) would involve adding:
Sybb := Sybb + close(i-2); Sxybb := Sxybb + i*close(i-2); bbb := (S*Sxybb - Sx*Sybb)/(S*Sxx - Sx*Sx);//Yesterday's slope
Then you'd not only look for when b>bb, but for when bb>bbb. And so on with Sybbb, Sxybbb, bbbb, etc.
But that is kludging to the factor of 10. I'll have to look at my daysback for loop some more to figure out where I went wrong ("Where did I go wrong in life!?")
You'd think the new variable "j" would work easily enough if you add to everything something like:
Syb := Syb + close(i-1-j);
But so far, no luck. I'll try looping the loop again later tonight. Barnstormin', ya know.
Brooke |