Here's a little indicator I coded a while back which displays the upper and lower band values when a bollinger band squeeze is on. The price lines disappear when the bands exit the squeeze. The idea is to place an entry bracket at price lines in anticipation of the breakout. Hope someone finds it useful.
Code:
inputs:
BollingerPrice( close),
bbLength( 13 ),
NumDevsUp( 2 ),
NumDevsDn( -2),
Displace( 0 ) ,
kPrice( Close ),
kLength( 13 ),
NumATRs( 1.5 ),
Plotbb(false);
variables:
bbAvg( 0 ),
kAvg(0),
SDev( 0 ),
bbLowerBand( 0 ),
bbUpperBand( 0 ),
Shift( 0 ),
kLowerBand( 0 ),
kUpperBand( 0 ),
decimals(autodecimals),
rndbbupperband(0),
rndbblowerband(0);
{bb}
bbAvg = AverageFC( BollingerPrice, bbLength ) ;
SDev = StandardDev( BollingerPrice, bbLength, 1 ) ;
bbUpperBand = bbAvg + NumDevsUp * SDev ;
bbLowerBand = bbAvg + NumDevsDn * SDev ;
{kc}
kAvg = AverageFC( kPrice, kLength ) ;
Shift = NumATRs * AvgTrueRange( kLength ) ;
kUpperBand = kAvg + Shift ;
kLowerBand = kAvg - Shift ;
{bb}
If plotbb=true then begin
if Displace >= 0 or CurrentBar > AbsValue( Displace ) then
begin
Plot1[Displace]( bbUpperBand, "UpperBand" ) ;
Plot2[Displace]( bbLowerBand, "LowerBand" ) ;
Plot3[Displace]( bbAvg, "MidLine" ) ;
end;
{kc}
if Displace >= 0 or CurrentBar > AbsValue( Displace ) then
begin
Plot4[Displace]( kUpperBand, "UpperBand" ) ;
Plot5[Displace]( kLowerBand, "LowerBand" ) ;
end;
end;
If bbUpperBand<=kUpperband or bbLowerband>=klowerband then begin
setplotcolor(1,yellow);
setplotcolor(2,yellow);
end;
if lastbaronchart then begin
value1=TL_new(currentdate, currenttime+5, bbUpperband, currentdate, currenttime+5, bbUpperband);
value2=TL_new(currentdate, currenttime+5, bbLowerband, currentdate, currenttime+5, bbLowerband);
TL_SetExtRight(1, true);
TL_SetExtRight(2, true);
TL_SetStyle(1, tool_solid);
TL_SetStyle(2, tool_solid);
TL_SetColor(1, yellow);
TL_SetColor(2, yellow);
TL_SetSize(1, 0);
TL_SetSize(2, 0);
rndbbupperband=roundinst(bbupperband);
rndbblowerband=roundinst(bblowerband);
value3=Text_New(Date, time, 0, numtostr(rndbbupperband,decimals));
Text_SetLocation(1, currentDate, currenttime+5, bbupperband);
Text_SetColor(1, green);
value4=Text_New(Date, Time, 0, numtostr(rndbblowerband,decimals));
Text_SetLocation(2, currentDate, currenttime+5, bblowerband);
Text_SetColor(2, red);
If bbUpperBand>=kUpperband or bbLowerband<=klowerband then begin
TL_Delete(1);
TL_Delete(2);
Text_Delete(1);
Text_Delete(2);
end;
end; Let me know if you have any issues. Squeezer.eld is the indicator. Auto Decimals.eld and RoundInst.eld are functions referenced in the indicator.