ViVen-Multi Time Frame Bollinger Band Strategy
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © moneyworld_99

//@version=5


indicator('ViVen-BB MTF', overlay=true, max_bars_back=500)

Vi = input.bool(true, title='On/Off All Indicators', group='⚡  DISPLAY INDICATORS ⚡ ')
BBInd = input.bool(true, title=' Display Bollinger Band', group='⚡  DISPLAY BOLLINGER BAND ⚡ ')
BBIndbl = input.bool(false, title=' BB Middle Line', group='⚡  DISPLAY BOLLINGER BAND ⚡ ')
BBInd5m = input.bool(true, title=' 5 Min BAND', group='⚡  DISPLAY BOLLINGER BAND ⚡ ')
BBInd15m = input.bool(true, title=' 15 Min BAND', group='⚡  DISPLAY BOLLINGER BAND ⚡ ')
BBInd30m = input.bool(false, title=' 30 Min BAND', group='⚡  DISPLAY BOLLINGER BAND ⚡ ')
BBInd1hr = input.bool(true, title=' 1 Hr BAND', group='⚡  DISPLAY BOLLINGER BAND ⚡ ')
BBInd1d = input.bool(false, title=' 1 Day BAND', group='⚡  DISPLAY BOLLINGER BAND ⚡ ')

bbmtf = input.timeframe(title='Bollinger Band MTF', defval='5', options=['5', '15', '30', '60', 'D'], group='INDICATOR INPUT 🔨')
bbmtf1 = input.timeframe(title='Bollinger Band MTF', defval='15', options=['5', '15', '30', '60', 'D'], group='INDICATOR INPUT 🔨')
bbmtf2 = input.timeframe(title='Bollinger Band MTF', defval='30', options=['5', '15', '30', '60', 'D'], group='INDICATOR INPUT 🔨')
bbmtf3 = input.timeframe(title='Bollinger Band MTF', defval='60', options=['5', '15', '30', '60', 'D'], group='INDICATOR INPUT 🔨')
bbmtf4 = input.timeframe(title='Bollinger Band MTF', defval='D', options=['5', '15', '30', '60', 'D'], group='INDICATOR INPUT 🔨')

emaPeriod = input.int(title='Bollinger Band Period', minval=1, maxval=50, defval=20, group='INDICATOR INPUT 🔨')

//CHART TITLE

alert_strings = array.new_string(3)
array.set(alert_strings, 0, '')
table_row_count = array.new_int(2)
array.set(table_row_count, 0, 1)
var UpTabl = table.new(position=position.top_center, columns=3, rows=10, bgcolor=color.rgb(255, 235, 59), border_width=1, frame_color=color.black, frame_width=1)
table.cell(table_id=UpTabl, column=2, row=0, text='▲ ViVen - Traders ▲')

//Boll Bands

devMultiple = 2
baseline = ta.sma(close, emaPeriod)

stdDeviation = devMultiple * ta.stdev(close, emaPeriod)
upperBand = baseline + stdDeviation
lowerBand = baseline - stdDeviation


// Plot the 15m BB
plotubb5m = request.security(syminfo.tickerid, bbmtf, upperBand)
plotlbb5m = request.security(syminfo.tickerid, bbmtf, lowerBand)
plotubb15m = request.security(syminfo.tickerid, bbmtf1, upperBand)
plotlbb15m = request.security(syminfo.tickerid, bbmtf1, lowerBand)
plotubb30m = request.security(syminfo.tickerid, bbmtf2, upperBand)
plotlbb30m = request.security(syminfo.tickerid, bbmtf2, lowerBand)
plotubb1h = request.security(syminfo.tickerid, bbmtf3, upperBand)
plotlbb1h = request.security(syminfo.tickerid, bbmtf3, lowerBand)
plotubb1d = request.security(syminfo.tickerid, bbmtf4, upperBand)
plotlbb1d = request.security(syminfo.tickerid, bbmtf4, lowerBand)

plot(Vi and BBInd and BBIndbl and baseline ? baseline : na, title = "BB Middle Line", color = color.orange, linewidth=2)
p1 = plot(Vi and BBInd and BBInd5m and plotubb5m ? plotubb5m : na, title='5M BB Top', color=color.blue)
p2 = plot(Vi and BBInd and BBInd5m and plotlbb5m ? plotlbb5m : na, title='5M BB Bottom', color=color.blue)
//fill(p1, p2, color = #DCE5E8)
plot(Vi and BBInd and BBInd15m and plotubb15m ? plotubb15m : na, title='15M BB Top', color=color.fuchsia)
plot(Vi and BBInd and BBInd15m and plotlbb15m ? plotlbb15m : na, title='15M BB Bottom', color=color.fuchsia)
plot(Vi and BBInd and BBInd30m and plotubb30m ? plotubb30m : na, title='30M BB Top', color=color.maroon)
plot(Vi and BBInd and BBInd30m and plotlbb30m ? plotlbb30m : na, title='30M BB Bottom', color=color.maroon)
plot(Vi and BBInd and BBInd1hr and plotubb1h ? plotubb1h : na, title='1Hr BB Top', color=color.white)
plot(Vi and BBInd and BBInd1hr and plotlbb1h ? plotlbb1h : na, title='1Hr BB Bottom', color=color.white)
plot(Vi and BBInd and BBInd1d and plotubb1d ? plotubb1d : na, title='1D BB Top', color=color.red)
plot(Vi and BBInd and BBInd1d and plotlbb1d ? plotlbb1d : na, title='1D BB Bottom', color=color.red)





