Hello, I've seen this nice piece of code that plots linear regression
code and was wondering if anyone could help me with a hint on how to
plot the channel two days ago and extend it into today. I've already
fried my brain, can't get it... thanks in advance.

SetBarsRequired(100000,0);
 bar = BarIndex();
 islastbar = bar == BarCount -10;
 isfirstbar = bar == BarCount - 100;
 firstbar = LastValue( ValueWhen( isfirstbar, bar ) );
 lastbar = LastValue( ValueWhen( islastbar, bar ) );
 al = LastValue( ValueWhen( islastbar, LinRegSlope( C, Lastbar -
firstbar + 1 ) ) );
 bl = LastValue( ValueWhen( islastbar, LinRegIntercept( C, Lastbar -
firstbar + 1 ) ) );
 Lr = al * ( BarIndex() - firstbar ) + bl;
 Lr = IIf( bar = firstbar AND bar <= lastbar , Lr, Null );
 se = StdErr(C,Lastbar - firstbar);
 se = LastValue( ValueWhen( islastbar, StdErr( C, Lastbar - firstbar +
1 ) ) );
 upper = Lr + se;
 Lower = Lr - se;

 Plot(Lr, "lr", colorYellow, styleThick );
 Plot(upper, "upper", colorGreen, styleThick );
 Plot(Lower, "lower", colorRed, styleThick );
 SetBarFillColor( IIf( C  O, colorBrightGreen, colorRed ) );
 Plot(C, "C", colorWhite, styleCandle );
 Title = "bar= " + bar + " firstbar= " + firstbar + " lastbar= " +
lastbar+ " se= "+ se; 


Reply via email to