Bulu Breakout
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © biswamca2010

//@version=4
study(title="Bulu Breakout",overlay=true)
//inputs
period=input(title="no of bars",type=input.integer,defval=52,minval=1,maxval=500)
timeframe=input(title="timeframe",type=input.string,defval="W")
alertcolor=input(title="alert bar color",type=input.color,defval=color.black)
ma=input(title="sma",type=input.integer,defval=44,minval=1,maxval=500)
[middle,upper,lower]=bb(close,20,2)
[diplus, diminus, adx] = dmi(14, 14)
hi=highest(period)
myhigh=security(syminfo.tickerid,timeframe,hi[1],barmerge.gaps_off,barmerge.lookahead_off)

bgcolor =close > myhigh and close >upper and adx<=30 ? alertcolor :na

barcolor(bgcolor)
plot(myhigh,title="52Whigh",color=alertcolor,linewidth=2)
plot(sma(close,ma))
plot(middle,title="MIDDLE BB")
plot(upper,title="UPPERBB")
plot(lower,title="LOWERBB")