Horizontal Lines Automatic
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © barnabygraham
//@version=5
indicator('Horizontal Lines Automatic [Technimentals]', overlay=true,max_lines_count=500)

toadd = 0.
incval = 0.
background = 0.
line1 = 0.
line2 = 0.

selectedprice = math.ceil(math.round(close)/10)*10

    
incval := input.float(title='Increment Value', defval=2.5)
toadd := incval
bool h = close > selectedprice + toadd
bool l = close < selectedprice - toadd
alertcondition(h, title='Cross UP', message='{{ticker}} crossed {{close}}')  //alert for when the price crosses the first upper interval
alertcondition(l, title='Cross DOWN', message='{{ticker}} crossed {{close}}')  //alert for when the price crosses the first lower interval
alertcondition(h or l, title='Cross UP/DOWN', message='{{ticker}} crossed {{close}}')  //alert for when the price crosses the first lower interval

colour=input.color(color.new(color.blue,65),'Line Colour')

n = bar_index
if barstate.islast
    base = line.new(n[1],selectedprice + toadd * 0,n,selectedprice + toadd * 0,extend=extend.both,color=colour)
    a1 = line.new(n[1],selectedprice + toadd * 1,n,selectedprice + toadd * 1,extend=extend.both,color=colour)
    b1 = line.new(n[1],selectedprice - toadd * 1,n,selectedprice - toadd * 1,extend=extend.both,color=colour)
    a2 = line.new(n[1],selectedprice + toadd * 2,n,selectedprice + toadd * 2,extend=extend.both,color=colour)
    b2 = line.new(n[1],selectedprice - toadd * 2,n,selectedprice - toadd * 2,extend=extend.both,color=colour)
    a3 = line.new(n[1],selectedprice + toadd * 3,n,selectedprice + toadd * 3,extend=extend.both,color=colour)
    b3 = line.new(n[1],selectedprice - toadd * 3,n,selectedprice - toadd * 3,extend=extend.both,color=colour)
    a4 = line.new(n[1],selectedprice + toadd * 4,n,selectedprice + toadd * 4,extend=extend.both,color=colour)
    b4 = line.new(n[1],selectedprice - toadd * 4,n,selectedprice - toadd * 4,extend=extend.both,color=colour)
    a5 = line.new(n[1],selectedprice + toadd * 5,n,selectedprice + toadd * 5,extend=extend.both,color=colour)
    b5 = line.new(n[1],selectedprice - toadd * 5,n,selectedprice - toadd * 5,extend=extend.both,color=colour)
    a6 = line.new(n[1],selectedprice + toadd * 6,n,selectedprice + toadd * 6,extend=extend.both,color=colour)
    b6 = line.new(n[1],selectedprice - toadd * 6,n,selectedprice - toadd * 6,extend=extend.both,color=colour)
    a7 = line.new(n[1],selectedprice + toadd * 7,n,selectedprice + toadd * 7,extend=extend.both,color=colour)
    b7 = line.new(n[1],selectedprice - toadd * 7,n,selectedprice - toadd * 7,extend=extend.both,color=colour)
    a8 = line.new(n[1],selectedprice + toadd * 8,n,selectedprice + toadd * 8,extend=extend.both,color=colour)
    b8 = line.new(n[1],selectedprice - toadd * 8,n,selectedprice - toadd * 8,extend=extend.both,color=colour)
    a9 = line.new(n[1],selectedprice + toadd * 9,n,selectedprice + toadd * 9,extend=extend.both,color=colour)
    b9 = line.new(n[1],selectedprice - toadd * 9,n,selectedprice - toadd * 9,extend=extend.both,color=colour)
    a10 = line.new(n[1],selectedprice + toadd * 10,n,selectedprice + toadd * 10,extend=extend.both,color=colour)
    b10 = line.new(n[1],selectedprice - toadd * 10,n,selectedprice - toadd * 10,extend=extend.both,color=colour)
    a11 = line.new(n[1],selectedprice + toadd * 11,n,selectedprice + toadd * 11,extend=extend.both,color=colour)
    b11 = line.new(n[1],selectedprice - toadd * 11,n,selectedprice - toadd * 11,extend=extend.both,color=colour)
    a12 = line.new(n[1],selectedprice + toadd * 12,n,selectedprice + toadd * 12,extend=extend.both,color=colour)
    b12 = line.new(n[1],selectedprice - toadd * 12,n,selectedprice - toadd * 12,extend=extend.both,color=colour)
    a13 = line.new(n[1],selectedprice + toadd * 13,n,selectedprice + toadd * 13,extend=extend.both,color=colour)
    b13 = line.new(n[1],selectedprice - toadd * 13,n,selectedprice - toadd * 13,extend=extend.both,color=colour)
    a14 = line.new(n[1],selectedprice + toadd * 14,n,selectedprice + toadd * 14,extend=extend.both,color=colour)
    b14 = line.new(n[1],selectedprice - toadd * 14,n,selectedprice - toadd * 14,extend=extend.both,color=colour)
    a15 = line.new(n[1],selectedprice + toadd * 15,n,selectedprice + toadd * 15,extend=extend.both,color=colour)
    b15 = line.new(n[1],selectedprice - toadd * 15,n,selectedprice - toadd * 15,extend=extend.both,color=colour)
    a16 = line.new(n[1],selectedprice + toadd * 16,n,selectedprice + toadd * 16,extend=extend.both,color=colour)
    b16 = line.new(n[1],selectedprice - toadd * 16,n,selectedprice - toadd * 16,extend=extend.both,color=colour)
    a17 = line.new(n[1],selectedprice + toadd * 17,n,selectedprice + toadd * 17,extend=extend.both,color=colour)
    b17 = line.new(n[1],selectedprice - toadd * 17,n,selectedprice - toadd * 17,extend=extend.both,color=colour)
    a18 = line.new(n[1],selectedprice + toadd * 18,n,selectedprice + toadd * 18,extend=extend.both,color=colour)
    b18 = line.new(n[1],selectedprice - toadd * 18,n,selectedprice - toadd * 18,extend=extend.both,color=colour)
    a19 = line.new(n[1],selectedprice + toadd * 19,n,selectedprice + toadd * 19,extend=extend.both,color=colour)
    b19 = line.new(n[1],selectedprice - toadd * 19,n,selectedprice - toadd * 19,extend=extend.both,color=colour)
    a20 = line.new(n[1],selectedprice + toadd * 20,n,selectedprice + toadd * 20,extend=extend.both,color=colour)
    b20 = line.new(n[1],selectedprice - toadd * 20,n,selectedprice - toadd * 20,extend=extend.both,color=colour)

    line.delete(base[1])
    line.delete(a1[1])
    line.delete(b1[1])
    line.delete(a2[1])
    line.delete(b2[1])
    line.delete(a3[1])
    line.delete(b3[1])
    line.delete(a4[1])
    line.delete(b4[1])
    line.delete(a5[1])
    line.delete(b5[1])
    line.delete(a6[1])
    line.delete(b6[1])
    line.delete(a7[1])
    line.delete(b7[1])
    line.delete(a8[1])
    line.delete(b8[1])
    line.delete(a9[1])
    line.delete(b9[1])
    line.delete(a10[1])
    line.delete(b10[1])
    line.delete(a11[1])
    line.delete(b11[1])
    line.delete(a12[1])
    line.delete(b12[1])
    line.delete(a13[1])
    line.delete(b13[1])
    line.delete(a14[1])
    line.delete(b14[1])
    line.delete(a15[1])
    line.delete(b15[1])
    line.delete(a16[1])
    line.delete(b16[1])
    line.delete(a17[1])
    line.delete(b17[1])
    line.delete(a18[1])
    line.delete(b18[1])
    line.delete(a19[1])
    line.delete(b19[1])
    line.delete(a20[1])
    line.delete(b20[1])




