PureBytes Links
Trading Reference Links
|
This wasn't written by me, sorry don't know where I picked it up...
Herman
///////////////////////////////////////////////////////
Period=150;
price=A;// choose price array
LinReg=( Period * Sum( Cum( 1 ) * price,Period ) -
Sum( Cum( 1 ),Period) * Sum( price,Period) ) /
(Period * Sum(Cum( 1 )^2,Period ) -
Sum( Cum( 1 ),Period )^2 ) * Cum( 1 ) + (MA(price,Period) -
MA( Cum(1 ),Period) * (Period * Sum( Cum( 1 ) * price,Period) -
Sum( Cum( 1 ),Period ) * Sum( price,Period) ) / (Period *
Sum( Cum(1 )^2 ,Period) - Sum( Cum( 1 ),Period )^2 ) );
ind=(LastValue(LinReg)-(LastValue(LinRegSlope(price,Period))*
(LastValue(Cum(1))-Cum(1))))+Ref(price,(0-(LastValue(Cum(1))-
Period)))-Ref(price,(0-(LastValue(Cum(1))-Period)));
Dist=ind*.05;// distance from regression
Plot( price, "Price", 1, 64);
Plot( ind, "Regression", 5, 1);
Plot( ind+Dist, "+Line", 6, 1);
Plot( ind-Dist, "-Line", 6, 1);
/////////////////////////////////////////////////////
|