AN EXAMPLE:
I don't know why your codes doesn't
work but building on what Graham wrote here's a an example (since I had to fight
through this at one time)
This is a snippet from one of my
indicators is based on Dimitris's work ....BB is the slope of the
line at the last bar. I write it
out on the chart
as follows
Title
= FullName()+" "+ Date()+"\n"+ "Slope of Regression Line(X1000) = "+ WriteVal(10000*bb);
If you're new to this script, I'd
recommend you take up one of the most productive practices I've found
and
adapt for your work. Find an
information database(I use Infoselect) for your system and clip every
interesting indicator or algorithm you
see used in this forum for your own
library. This of course would be in addition to what Graham recommended
2-3 weeks back...going through each function and using the function in a test
program .
Searching the archives 2-3 years
back for Graham's and Dimitris Tsokakis' work would also pay off.
Best regards
JOE
// Plot the slope of the relative strength line
//
Daysback = 126; // 6 months
x = Cum(1); // the X axis, abscissa
LastX = LastValue(X);
C1 = Issue2Rel; // the Y axis, the ordinate
aa = LastValue( LinRegIntercept( C1, Daysback) );
bb = LastValue( LinRegSlope( C1, Daysback ) );
yy = Aa + bb * ( x - (Lastx - DaysBack) ); // the
algebraic equation for a straight line
yy=IIf( x >= (lastx - Daysback), yy, -1e10 ); // roll the plot forward and
show only the 6 months
Plot
( yy,
"LinRegression Line",
colorDarkRed,
styleThick);
UpperSEBand = YY + 2*StdErr(Issue2Rel,126);
LowerSEBand = YY - 2*StdErr(Issue2Rel,126);
Plot
(UpperSEBand,
"Upper 2
Sigma",
colorBlue,
styleLine);
Plot
(LowerSEband,
"Lower 2
Sigma",
colorBlue,
styleLine);