/*[[
	Name := Bollinger BWidth
	Author := Kamen Nyagolov
	Separate Window := Yes
	First Color := Red
	First Draw Type := Line
	First Symbol := 217
	Use Second Data := Yes
	Second Color := White
	Second Draw Type := Line
	Second Symbol := 218
]]*/
Variable : UpperBB(0), LowerBB(0), MiddleBB(0),shift(0);
Input : PercentLine(3);

SetLoopCount(0);
// loop from first bar to current bar (with shift=0)
For shift=Bars Downto 0 Begin
	UpperBB = iBands(20,2,MODE_HIGH,shift);
	LowerBB = iBands(20,2,MODE_LOW,shift);
	MiddleBB = iBands(20,2,MODE_MAIN,shift);
	SetIndexValue(shift,((UpperBB-LowerBB)/MiddleBB)*1000);
	SetIndexValue2(shift, PercentLine);
End;
