{ Extreme Channel Shifted Version }
Daysback:= Input("Period for Liner Regression Line", 20,720,283);
shift:= Input("Look back period",0,600,0); x:= Cum(1);
lastx:= LastValue( x ) - shift;
aa:=LastValue(Ref(LinearReg(C,Daysback),-Shift)-Ref(LinRegSlope(C,Daysback),-Shift)*Daysback);
bb:= LastValue( Ref(LinRegSlope( C, Daysback ), -shift) );
y:= aa+bb*(x-(Lastx - DaysBack +1 ) );
LRLine:= ValueWhen(1,( x > (lastx-Daysback) AND (Cum(1)-1) < Lastx), y);
restrictedLine:=Ref(Ref(LRline,-shift),shift)*ValueWhen(1,(shift+daysback),1);
restrictedLine;
SD:=Input("Standard Error" ,1,6,2.618);
width:= LastValue( Ref(SD*STE(P, Daysback),-shift));
SDL:= If( x > (lastx - Daysback) AND (Cum(1)-1) < Lastx, y-width , 0) ;
SDU:= ValueWhen(1,( x > (lastx - Daysback) AND (Cum(1)-1) < Lastx) , y+width );
restrictedU:=Ref(Ref(SDU,-shift),shift)*ValueWhen(1,(shift+daysback),1);
restrictedU;
SDL:= ValueWhen(1,( x > (lastx - Daysback) AND (Cum(1)-1) < Lastx), y-width );
restrictedL:=Ref(Ref(SDL,-shift),shift)*ValueWhen(1,(shift+daysback),1);
restrictedL;
{ ===== Standard Error" , 1.618 ====== }
SD:=Input("Standard Error" ,1,3, 1.618);
width:= LastValue( Ref(SD*STE(P, Daysback),-shift));
SDL:= If( x > (lastx - Daysback) AND (Cum(1)-1) < Lastx, y-width , 0) ;
SDU:= ValueWhen(1,( x > (lastx - Daysback) AND (Cum(1)-1) < Lastx) , y+width );
restrictedU:=Ref(Ref(SDU,-shift),shift)*ValueWhen(1,(shift+daysback),1);
restrictedU;
SDL:= ValueWhen(1,( x > (lastx - Daysback) AND (Cum(1)-1) < Lastx), y-width );
restrictedL:=Ref(Ref(SDL,-shift),shift)*ValueWhen(1,(shift+daysback),1);
restrictedL;
{ ===== Standard Error" , 1..27 ====== }
SD:=Input("Standard Error" ,1,3, 1.27);
width:= LastValue( Ref(SD*STE(P, Daysback),-shift));
SDL:= If( x > (lastx - Daysback) AND (Cum(1)-1) < Lastx, y-width , 0) ;
SDU:= ValueWhen(1,( x > (lastx - Daysback) AND (Cum(1)-1) < Lastx) , y+width );
restrictedU:=Ref(Ref(SDU,-shift),shift)*ValueWhen(1,(shift+daysback),1);
restrictedU;
SDL:= ValueWhen(1,( x > (lastx - Daysback) AND (Cum(1)-1) < Lastx), y-width );
restrictedL:=Ref(Ref(SDL,-shift),shift)*ValueWhen(1,(shift+daysback),1);
restrictedL;