Round Numbers and Quarter Levels
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © bluebeardit

//
//  ________   ___        ___  ___   _______    ________   _______    ________   ________   ________   ___   _________   
// |\   __  \ |\  \      |\  \|\  \ |\  ___ \  |\   __  \ |\  ___ \  |\   __  \ |\   __  \ |\   ___ \ |\  \ |\___   ___\ 
// \ \  \|\ /_\ \  \     \ \  \\\  \\ \   __/| \ \  \|\ /_\ \   __/| \ \  \|\  \\ \  \|\  \\ \  \_|\ \\ \  \\|___ \  \_| 
//  \ \   __  \\ \  \     \ \  \\\  \\ \  \_|/__\ \   __  \\ \  \_|/__\ \   __  \\ \   _  _\\ \  \ \\ \\ \  \    \ \  \  
//   \ \  \|\  \\ \  \____ \ \  \\\  \\ \  \_|\ \\ \  \|\  \\ \  \_|\ \\ \  \ \  \\ \  \\  \|\ \  \_\\ \\ \  \    \ \  \ 
//    \ \_______\\ \_______\\ \_______\\ \_______\\ \_______\\ \_______\\ \__\ \__\\ \__\\ _\ \ \_______\\ \__\    \ \__\
//     \|_______| \|_______| \|_______| \|_______| \|_______| \|_______| \|__|\|__| \|__|\|__| \|_______| \|__|     \|__|
// 
//
//  V. 1.0
//This script is based on "Round Numbers Above and Below" by BitcoinJesus-Not-Roger-Ver
//@version=5

indicator("Round numbers and quarter levels", shorttitle="Round Num & Q. Lev", overlay=true)

//User input Round 00
var GRP1 = "Round 00 Numbers"
linecolor1 = input(title="Line color", defval = color.blue, group = GRP1)
linestyle1 = input.string(title="Line style", defval = line.style_solid, options=[line.style_solid, line.style_dotted, line.style_dashed], group = GRP1)
linewidth1 = input.int(title="Line width", defval = 2, minval=1, maxval=4, group = GRP1)

//User input Round 50
var GRP2 = "Round 50 Numbers"
linecolor2 = input(title="Line color", defval = color.orange, group = GRP2)
linestyle2 = input.string(title="Line style", defval = line.style_solid, options=[line.style_solid, line.style_dotted, line.style_dashed], group = GRP2)
linewidth2 = input.int(title="Line width", defval = 1, minval=1, maxval=4, group = GRP2)

//User input Quarters
var GRP3 = "Quarter Numbers"
linecolor3 = input(title="Line color", defval = color.green, group = GRP3)
linestyle3 = input.string(title="Line style", defval = line.style_dashed, options=[line.style_solid, line.style_dotted, line.style_dashed], group = GRP3)
linewidth3 = input.int(title="Line width", defval = 1, minval=1, maxval=4, group = GRP3)


var number_of_lines = input.int(4, title="Number of lines above/below")

var step = syminfo.mintick*250
if barstate.islast 
    for counter = 0 to number_of_lines - 1
        stepUp = math.ceil(close / step) * step + (counter * step)
        line.new(bar_index, stepUp, bar_index - 1, stepUp, xloc=xloc.bar_index, extend=extend.both, color=linecolor3, width=linewidth3, style=linestyle3)
        stepDown = math.floor(close / step) * step - (counter * step)
        line.new(bar_index, stepDown, bar_index - 1, stepDown, xloc=xloc.bar_index, extend=extend.both, color=linecolor3, width=linewidth3, style=linestyle3)
        

var step2 = syminfo.mintick*500
if barstate.islast 
    for counter = 0 to (number_of_lines /2) - 1
        stepUp = math.ceil(close / step2) * step2 + (counter * step2)
        line.new(bar_index, stepUp, bar_index - 1, stepUp, xloc=xloc.bar_index, extend=extend.both, color=linecolor2, width=linewidth2, style=linestyle2)
        stepDown = math.floor(close / step2) * step2 - (counter * step2)
        line.new(bar_index, stepDown, bar_index - 1, stepDown, xloc=xloc.bar_index, extend=extend.both, color=linecolor2, width=linewidth2, style=linestyle2)
        

var step3 = syminfo.mintick*1000
if barstate.islast 
    for counter = 0 to (number_of_lines /4) - 1
        stepUp = math.ceil(close / step3) * step3 + (counter * step3)
        line.new(bar_index, stepUp, bar_index - 1, stepUp, xloc=xloc.bar_index, extend=extend.both, color=linecolor1, width=linewidth1, style=linestyle1)
        stepDown = math.floor(close / step3) * step3 - (counter * step3)
        line.new(bar_index, stepDown, bar_index - 1, stepDown, xloc=xloc.bar_index, extend=extend.both, color=linecolor1, width=linewidth1, style=linestyle1)