RicardoSantos

[RS]Bollinger Bands Stop V0

request for: kapparam.
Remove from Favorite Scripts Add to Favorite Scripts
study(title='[RS]Bollinger Bands Stop V0', shorttitle='BBS', overlay=true)
bb_src = input(title='Bollinger Band Source:', type=source, defval=close)
stop_src = input(title='Stop Source:', type=source, defval=close)
length = input(title='Length', type=integer, defval=20, minval=1)
mult = input(title='Band Deviation Multiplier:', type=float, defval=2.0, minval=0.001, maxval=50)
risk_multiplier = input(title='Risk Multiplier:', type=float, defval=0.5, minval=0.001, maxval=50)
SHOW_BB = input(title='Show Bollinger Bands?', type=bool, defval=false)
SHOW_ENTRY_ZONE = input(title='Show Entry Zone?', type=bool, defval=false)
SHOW_POINTS = input(title='Show Points?', type=bool, defval=false)

basis = sma(bb_src, length)
dev = mult * stdev(bb_src, length)
upper = basis + dev
lower = basis - dev

plot(title='BB-M', series=not SHOW_BB ? na : basis, color=gray)
p1 = plot(title='BB-U', series=not SHOW_BB ? na : upper, color=silver)
p2 = plot(title='BB-L', series=not SHOW_BB ? na : lower, color=silver)
fill(p1, p2, color=black, transp=90, title='BBf', editable=true)

trend = na(trend[1]) ? 1 : stop_src > upper[1] ? +1 : stop_src < lower[1] ? -1 : trend[1]

smin = trend < 0 ? min(nz(smin[1], upper[1]), upper) : na
smax = trend > 0 ? max(nz(smax[1], lower[1]), lower) : na

adjusted_min = trend < 0 ? min(nz(adjusted_min[1], smin[1]), smin - (risk_multiplier * dev)) : na
adjusted_max = trend > 0 ? max(nz(adjusted_max[1], smax[1]), smax + (risk_multiplier * dev)) : na

s0 = plot(title='S-', series=smin, style=linebr, color=black, transp=0)
s1 = plot(title='S+', series=smax, style=linebr, color=black, transp=0)
s2 = plot(title='E-', series=not SHOW_ENTRY_ZONE ? na : adjusted_min, style=linebr, color=black, transp=0)
s3 = plot(title='E+', series=not SHOW_ENTRY_ZONE ? na : adjusted_max, style=linebr, color=black, transp=0)
fill(s0, s2, color=red, transp=80, title='Z-', editable=true)
fill(s1, s3, color=lime, transp=80, title='Z+', editable=true)

overbought_end = crossunder(stop_src, upper)
oversold_end = crossover(stop_src, lower)

buy_entry_zone = stop_src < adjusted_max and stop_src > smax
sel_entry_zone = stop_src > adjusted_min and stop_src < smin

plot(title='Bz', series=not SHOW_POINTS ? na : buy_entry_zone ? low : na, style=circles, color=green, transp=0, linewidth=4)
plot(title='Sz', series=not SHOW_POINTS ? na : sel_entry_zone ? high : na, style=circles, color=maroon, transp=0, linewidth=4)
plot(title='Be', series=not SHOW_POINTS ? na : overbought_end ? high : na, style=circles, color=black, transp=0, linewidth=4)
plot(title='Se', series=not SHOW_POINTS ? na : oversold_end ? low : na, style=circles, color=black, transp=0, linewidth=4)
dave.seremek PRO
10 months ago
What do the red, green and black dots signify?
Reply
RicardoSantos PRO dave.seremek
10 months ago
sell, buy, close zones
sell/buy when price test the 2 lines zone
close when price is out of bounds of the BB's
Reply
vaicru PRO
10 months ago
Can I use it daily ?
Reply
vaicru PRO vaicru
10 months ago
(daily timeframe ! )
Reply
RicardoSantos PRO vaicru
10 months ago
can use at any timeframe, would need to adjust values for market conditions tho.
Reply
coondawg71 PRO
10 months ago
Nice tool guys ! Another nice display of coding Ricardo.
Reply
RicardoSantos PRO coondawg71
10 months ago
thx :p
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out