Try this: /*The code Herman posted few days back, see subject: "AFL for Linear Regression Study" does that, see parameter window "Extend". I also wrote some code few years back (see below). "Future" points are displayed using styleDots,*/ per = 20; fut = 5; //mm = (H + L + C) / 3; mm = C;
x = Cum(1); lastx = LastValue(x); selv = SelectedValue(x); aaa = LinRegIntercept(mm, per); bbb = LinRegSlope(mm, per); daa = SelectedValue(ValueWhen(x, aaa, 1)); dbb = SelectedValue(ValueWhen(x, bbb, 1)); xx = IIf(x > selv - per AND x <= selv, x - (selv - per),Null); yy = daa + dbb * xx; fxx = IIf(x > selv AND x <= selv + fut, x - (selv - per),Null); fyy = daa + dbb * fxx; wd = SelectedValue(StDev(mm,per)); SetChartOptions(0, chartShowDates); Plot(yy, "LinReg", colorBlue, 1); Plot(yy + wd, "Upper Boundary", colorRed, 1); Plot(yy - wd, "Lower Boundary", colorBrightGreen, 1); // plot into future Plot(fyy, "LinReg", colorBlue ,styleDots | styleNoLine); Plot(fyy + wd, "Upper Boundary", colorRed ,styleDots | styleNoLine); Plot(fyy - wd, "Lower Boundary", colorBrightGreen ,styleDots | styleNoLine); Plot(C,"",colorBlack,64); Dick H --- In [email protected], "austin.lawrence24" <austin.lawrenc...@...> wrote: > > Would anyone know the formula used to calculate the LinearReg function as > used in AmiBroker. > > Thanks to anyone who can help. >
