Draw Several Horizontal Lines [MsF]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Trader_Morry

//@version=5
indicator(title='Draw Several Horizontal Lines [MsF]', shorttitle='Draw H.Lines', overlay=true, max_bars_back = 5000)

////////
// Input values 
// [
var GRP1 = "--- Horizontal Lines setting ---"
iDisplay_01       = input.bool(defval = true, title = "01", group = GRP1, inline = "01")
iSymbol_01        = input.symbol(defval = "OANDA:XAUUSD", title = "", group = GRP1, inline = "01")
iHUpperValue_01   = input.float(defval = 1815, title = "H", group = GRP1, inline = "01")
iHLowerValue_01   = input.float(defval = 1810, title = "L", group = GRP1, inline = "01")
iDisplay_02       = input.bool(defval = true, title = "02", group = GRP1, inline = "02")
iSymbol_02        = input.symbol(defval = "OANDA:USDJPY", title = "", group = GRP1, inline = "02")
iHUpperValue_02   = input.float(defval = 138, title = "H", group = GRP1, inline = "02")
iHLowerValue_02   = input.float(defval = 136, title = "L", group = GRP1, inline = "02")
iDisplay_03       = input.bool(defval = true, title = "03", group = GRP1, inline = "03")
iSymbol_03        = input.symbol(defval = "OANDA:EURUSD", title = "", group = GRP1, inline = "03")
iHUpperValue_03   = input.float(defval = 1.06, title = "H", group = GRP1, inline = "03")
iHLowerValue_03   = input.float(defval = 1.05, title = "L", group = GRP1, inline = "03")
iDisplay_04       = input.bool(defval = true, title = "04", group = GRP1, inline = "04")
iSymbol_04        = input.symbol(defval = "OANDA:EURJPY", title = "", group = GRP1, inline = "04")
iHUpperValue_04   = input.float(defval = 145.568, title = "H", group = GRP1, inline = "04")
iHLowerValue_04   = input.float(defval = 144.193, title = "L", group = GRP1, inline = "04")
iDisplay_05       = input.bool(defval = true, title = "05", group = GRP1, inline = "05")
iSymbol_05        = input.symbol(defval = "OANDA:GBPUSD", title = "", group = GRP1, inline = "05")
iHUpperValue_05   = input.float(defval = 1.19, title = "H", group = GRP1, inline = "05")
iHLowerValue_05   = input.float(defval = 1.17, title = "L", group = GRP1, inline = "05")
iDisplay_06       = input.bool(defval = true, title = "06", group = GRP1, inline = "06")
iSymbol_06        = input.symbol(defval = "OANDA:GBPJPY", title = "", group = GRP1, inline = "06")
iHUpperValue_06   = input.float(defval = 164, title = "H", group = GRP1, inline = "06")
iHLowerValue_06   = input.float(defval = 161, title = "L", group = GRP1, inline = "06")
iDisplay_07       = input.bool(defval = true, title = "07", group = GRP1, inline = "07")
iSymbol_07        = input.symbol(defval = "OANDA:AUDUSD", title = "", group = GRP1, inline = "07")
iHUpperValue_07   = input.float(defval = 0.66, title = "H", group = GRP1, inline = "07")
iHLowerValue_07   = input.float(defval = 0.64, title = "L", group = GRP1, inline = "07")
iDisplay_08       = input.bool(defval = true, title = "08", group = GRP1, inline = "08")
iSymbol_08        = input.symbol(defval = "OANDA:AUDJPY", title = "", group = GRP1, inline = "08")
iHUpperValue_08   = input.float(defval = 92, title = "H", group = GRP1, inline = "08")
iHLowerValue_08   = input.float(defval = 90, title = "L", group = GRP1, inline = "08")
iDisplay_09       = input.bool(defval = true, title = "09", group = GRP1, inline = "09")
iSymbol_09        = input.symbol(defval = "OANDA:GBPAUD", title = "", group = GRP1, inline = "09")
iHUpperValue_09   = input.float(defval = 1.81, title = "H", group = GRP1, inline = "09")
iHLowerValue_09   = input.float(defval = 1.78, title = "L", group = GRP1, inline = "09")
iDisplay_10       = input.bool(defval = true, title = "10", group = GRP1, inline = "10")
iSymbol_10        = input.symbol(defval = "OANDA:EURAUD", title = "", group = GRP1, inline = "10")
iHUpperValue_10   = input.float(defval = 1.62, title = "H", group = GRP1, inline = "10")
iHLowerValue_10   = input.float(defval = 1.58, title = "L", group = GRP1, inline = "10")
iBandCount        = input.int(defval = 6, minval = 1, maxval = 10, title = "Band Lines Count", group = GRP1)
iUnitedIndividual = "united" //input.string(title='Line Type setting', defval="united", options=["united", "individual"], group = GRP1)
var GRP2 = "--- United Line Type setting ---"
iMainLineColor    = input.color(defval = color.yellow, title = "Color", group = GRP2, inline = "main")
iMainLineWidth    = input.int(defval = 2, title = "Width", group = GRP2, inline = "main")
iMainLineStyle    = input.string(title='Style', defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP2, inline = "main")
iSubLineColor     = input.color(defval = color.rgb(255,235,59,80), title = "Color", group = GRP2, inline = "sub")
iSubLineWidth     = input.int(defval = 2, title = "Width", group = GRP2, inline = "sub")
iSubLineStyle     = input.string(title='Style', defval=line.style_dashed, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP2, inline = "sub")
//var GRP3 = "--- Individual Line Type setting ---"
iMainLineColor_01 = iMainLineColor //input.color(defval = color.yellow, title = "01-M", group = GRP3, inline = "11")
iMainLineWidth_01 = iMainLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "11")
iMainLineStyle_01 = iMainLineStyle //input.string(title='Style', defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "11")
iSubLineColor_01  = iSubLineColor //input.color(defval = color.rgb(255,235,59,80), title = "01-S", group = GRP3, inline = "12")
iSubLineWidth_01  = iSubLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "12")
iSubLineStyle_01  = iSubLineStyle //input.string(title='Style', defval=line.style_dashed, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "12")
iMainLineColor_02 = iMainLineColor //input.color(defval = color.yellow, title = "02-M", group = GRP3, inline = "21")
iMainLineWidth_02 = iMainLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "21")
iMainLineStyle_02 = iMainLineStyle //input.string(title='Style', defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "21")
iSubLineColor_02  = iSubLineColor //input.color(defval = color.rgb(255,235,59,80), title = "02-S", group = GRP3, inline = "22")
iSubLineWidth_02  = iSubLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "22")
iSubLineStyle_02  = iSubLineStyle //input.string(title='Style', defval=line.style_dashed, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "22")
iMainLineColor_03 = iMainLineColor //input.color(defval = color.yellow, title = "03-M", group = GRP3, inline = "31")
iMainLineWidth_03 = iMainLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "31")
iMainLineStyle_03 = iMainLineStyle //input.string(title='Style', defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "31")
iSubLineColor_03  = iSubLineColor //input.color(defval = color.rgb(255,235,59,80), title = "03-S", group = GRP3, inline = "32")
iSubLineWidth_03  = iSubLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "32")
iSubLineStyle_03  = iSubLineStyle //input.string(title='Style', defval=line.style_dashed, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "32")
iMainLineColor_04 = iMainLineColor //input.color(defval = color.yellow, title = "04-M", group = GRP3, inline = "41")
iMainLineWidth_04 = iMainLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "41")
iMainLineStyle_04 = iMainLineStyle //input.string(title='Style', defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "41")
iSubLineColor_04  = iSubLineColor //input.color(defval = color.rgb(255,235,59,80), title = "04-S", group = GRP3, inline = "42")
iSubLineWidth_04  = iSubLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "42")
iSubLineStyle_04  = iSubLineStyle //input.string(title='Style', defval=line.style_dashed, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "42")
iMainLineColor_05 = iMainLineColor //input.color(defval = color.yellow, title = "05-M", group = GRP3, inline = "51")
iMainLineWidth_05 = iMainLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "51")
iMainLineStyle_05 = iMainLineStyle //input.string(title='Style', defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "51")
iSubLineColor_05  = iSubLineColor //input.color(defval = color.rgb(255,235,59,80), title = "05-S", group = GRP3, inline = "52")
iSubLineWidth_05  = iSubLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "52")
iSubLineStyle_05  = iSubLineStyle //input.string(title='Style', defval=line.style_dashed, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "52")
iMainLineColor_06 = iMainLineColor //input.color(defval = color.yellow, title = "06-M", group = GRP3, inline = "61")
iMainLineWidth_06 = iMainLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "61")
iMainLineStyle_06 = iMainLineStyle //input.string(title='Style', defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "61")
iSubLineColor_06  = iSubLineColor //input.color(defval = color.rgb(255,235,59,80), title = "06-S", group = GRP3, inline = "62")
iSubLineWidth_06  = iSubLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "62")
iSubLineStyle_06  = iSubLineStyle //input.string(title='Style', defval=line.style_dashed, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "62")
iMainLineColor_07 = iMainLineColor //input.color(defval = color.yellow, title = "07-M", group = GRP3, inline = "71")
iMainLineWidth_07 = iMainLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "71")
iMainLineStyle_07 = iMainLineStyle //input.string(title='Style', defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "71")
iSubLineColor_07  = iSubLineColor //input.color(defval = color.rgb(255,235,59,80), title = "07-S", group = GRP3, inline = "72")
iSubLineWidth_07  = iSubLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "72")
iSubLineStyle_07  = iSubLineStyle //input.string(title='Style', defval=line.style_dashed, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "72")
iMainLineColor_08 = iMainLineColor //input.color(defval = color.yellow, title = "08-M", group = GRP3, inline = "81")
iMainLineWidth_08 = iMainLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "81")
iMainLineStyle_08 = iMainLineStyle //input.string(title='Style', defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "81")
iSubLineColor_08  = iSubLineColor //input.color(defval = color.rgb(255,235,59,80), title = "08-S", group = GRP3, inline = "82")
iSubLineWidth_08  = iSubLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "82")
iSubLineStyle_08  = iSubLineStyle //input.string(title='Style', defval=line.style_dashed, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "82")
iMainLineColor_09 = iMainLineColor //input.color(defval = color.yellow, title = "09-M", group = GRP3, inline = "91")
iMainLineWidth_09 = iMainLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "91")
iMainLineStyle_09 = iMainLineStyle //input.string(title='Style', defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "91")
iSubLineColor_09  = iSubLineColor //input.color(defval = color.rgb(255,235,59,80), title = "09-S", group = GRP3, inline = "92")
iSubLineWidth_09  = iSubLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "92")
iSubLineStyle_09  = iSubLineStyle //input.string(title='Style', defval=line.style_dashed, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "92")
iMainLineColor_10 = iMainLineColor //input.color(defval = color.yellow, title = "10-M", group = GRP3, inline = "01")
iMainLineWidth_10 = iMainLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "01")
iMainLineStyle_10 = iMainLineStyle //input.string(title='Style', defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "01")
iSubLineColor_10  = iSubLineColor //input.color(defval = color.rgb(255,235,59,80), title = "10-S", group = GRP3, inline = "02")
iSubLineWidth_10  = iSubLineWidth //input.int(defval = 2, title = "Width", group = GRP3, inline = "02")
iSubLineStyle_10  = iSubLineStyle //input.string(title='Style', defval=line.style_dashed, options=[line.style_dotted, line.style_dashed, line.style_solid], group = GRP3, inline = "02")
// ]

// Defines
// [
// ]

// Prepare
// [
// ]

// Functions
// [
// Drawing Horizontal Lines Function
//   [
drawing_Horizontal_Lines(aHUpperValue, aHLowerValue, aMainLineColor, aMainLineWidth, aMainLineStyle, aSubLineColor, aSubLineWidth, aSubLineStyle) =>
    //Lines type setting
    var color  _color = na
    var int    _width = 0
    var string _style = ""
    if iUnitedIndividual == "united"
        _color := iMainLineColor
        _width := iMainLineWidth
        _style := iMainLineStyle
    else
        _color := aMainLineColor
        _width := aMainLineWidth
        _style := aMainLineStyle
    //for horizontal lines
    _Mainpips = math.abs(aHUpperValue-aHLowerValue)
    hSubValue = aHUpperValue-_Mainpips
    _bandPips = _Mainpips / 2
    // Draw base line
    var line line_Base = na
    line.delete(line_Base)
    line_Base := line.new(bar_index, hSubValue, bar_index+1, hSubValue, extend = extend.both, color = _color, width = _width, style = _style)
    // Draw band line
    var line line_Band_Upper = na
    var line line_Band_Lower = na
    // Draw Band Lines
    for cnt = 1 to iBandCount
        if cnt%2==0 //偶数
            if iUnitedIndividual == "united"
                _color := iMainLineColor
                _width := iMainLineWidth
                _style := iMainLineStyle
            else
                _color := aMainLineColor
                _width := aMainLineWidth
                _style := aMainLineStyle
        else //奇数
            if iUnitedIndividual == "united"
                _color := iSubLineColor
                _width := iSubLineWidth
                _style := iSubLineStyle
            else
                _color := aSubLineColor
                _width := aSubLineWidth
                _style := aSubLineStyle
        line_Band_Upper := line.new(bar_index, hSubValue+_bandPips*cnt, bar_index+1, hSubValue+_bandPips*cnt, extend = extend.both, color = _color, width = _width, style = _style)
        line_Band_Lower := line.new(bar_index, hSubValue-_bandPips*cnt, bar_index+1, hSubValue-_bandPips*cnt, extend = extend.both, color = _color, width = _width, style = _style)
//   ]
// ]

// Main Program
// [
// Draw horizontal line
//   [
if barstate.islast
    if iDisplay_01 and syminfo.ticker == syminfo.ticker(iSymbol_01)
        drawing_Horizontal_Lines(iHUpperValue_01, iHLowerValue_01, iMainLineColor_01, iMainLineWidth_01, iMainLineStyle_01, iSubLineColor_01, iSubLineWidth_01, iSubLineStyle_01)
    if iDisplay_02 and syminfo.ticker == syminfo.ticker(iSymbol_02)
        drawing_Horizontal_Lines(iHUpperValue_02, iHLowerValue_02, iMainLineColor_02, iMainLineWidth_02, iMainLineStyle_02, iSubLineColor_02, iSubLineWidth_02, iSubLineStyle_02)
    if iDisplay_03 and syminfo.ticker == syminfo.ticker(iSymbol_03)
        drawing_Horizontal_Lines(iHUpperValue_03, iHLowerValue_03, iMainLineColor_03, iMainLineWidth_03, iMainLineStyle_03, iSubLineColor_03, iSubLineWidth_03, iSubLineStyle_03)
    if iDisplay_04 and syminfo.ticker == syminfo.ticker(iSymbol_04)
        drawing_Horizontal_Lines(iHUpperValue_04, iHLowerValue_04, iMainLineColor_04, iMainLineWidth_04, iMainLineStyle_04, iSubLineColor_04, iSubLineWidth_04, iSubLineStyle_04)
    if iDisplay_05 and syminfo.ticker == syminfo.ticker(iSymbol_05)
        drawing_Horizontal_Lines(iHUpperValue_05, iHLowerValue_05, iMainLineColor_05, iMainLineWidth_05, iMainLineStyle_05, iSubLineColor_05, iSubLineWidth_05, iSubLineStyle_05)
    if iDisplay_06 and syminfo.ticker == syminfo.ticker(iSymbol_06)
        drawing_Horizontal_Lines(iHUpperValue_06, iHLowerValue_06, iMainLineColor_06, iMainLineWidth_06, iMainLineStyle_06, iSubLineColor_06, iSubLineWidth_06, iSubLineStyle_06)
    if iDisplay_07 and syminfo.ticker == syminfo.ticker(iSymbol_07)
        drawing_Horizontal_Lines(iHUpperValue_07, iHLowerValue_07, iMainLineColor_07, iMainLineWidth_07, iMainLineStyle_07, iSubLineColor_07, iSubLineWidth_07, iSubLineStyle_07)
    if iDisplay_08 and syminfo.ticker == syminfo.ticker(iSymbol_08)
        drawing_Horizontal_Lines(iHUpperValue_08, iHLowerValue_08, iMainLineColor_08, iMainLineWidth_08, iMainLineStyle_08, iSubLineColor_08, iSubLineWidth_08, iSubLineStyle_08)
    if iDisplay_09 and syminfo.ticker == syminfo.ticker(iSymbol_09)
        drawing_Horizontal_Lines(iHUpperValue_09, iHLowerValue_09, iMainLineColor_09, iMainLineWidth_09, iMainLineStyle_09, iSubLineColor_09, iSubLineWidth_09, iSubLineStyle_09)
    if iDisplay_10 and syminfo.ticker ==syminfo.ticker( iSymbol_10)
        drawing_Horizontal_Lines(iHUpperValue_10, iHLowerValue_10, iMainLineColor_10, iMainLineWidth_10, iMainLineStyle_10, iSubLineColor_10, iSubLineWidth_10, iSubLineStyle_10)
//   ]

//// Alert
//   [
//   ]
// ]
