Quarter theory and whole numbers
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Rain5369

//@version=5
indicator('Quarter Levels', overlay=true)

var largeLines = 2
var majorLines = 4
var picoLines = 8
var femtoLines = 8

StepSize = input.float(1000, title='Step Size [pip]', step=0.00001, tooltip = 'The value That should be entered here is 1000 pips. e.g. FX = 1000, BTC(depends on decimal point)- 10 000/ 100 000, ETH(depends on decimal point) - 1 000/10 000')
var step = syminfo.mintick * (StepSize*10)
var majorStep = syminfo.mintick * (StepSize*2.5)
var picoStep = syminfo.mintick * (StepSize*1)
var FemtoStep = syminfo.mintick * (StepSize*0.25)

line ln = na
lstyle1 = input.string(title='Resistance Line Style', defval='Solid', options=['Solid', 'Dotted', 'Dashed'], group='Resistance')
lstyle2 = input.string(title='Support Line Style', defval='Solid', options=['Solid', 'Dotted', 'Dashed'], group='Support')
resistanceStyle = lstyle1 == 'Solid' ? line.style_solid : lstyle1 == 'Dotted' ? line.style_dotted : line.style_dashed
supportStyle = lstyle2 == 'Solid' ? line.style_solid : lstyle2 == 'Dotted' ? line.style_dotted : line.style_dashed

LineCol = input.color(color.new(#FFFFFF, 0), title='1000 pip', inline='LineCol', group='Resistance')
lineWidth = input.int(3, title='', minval=1, maxval=4, inline='LineCol', group='Resistance')

LineCol2 = input.color(color.new(#FFFFFF, 0), title='1000 pip', inline='LineCol2', group='Support')
lineWidth2 = input.int(3, title='', minval=1, maxval=4, inline='LineCol2', group='Support')


LineCol3 = input.color(color.new(#FFFFFF, 50), title='250 pip', inline='LineCol3', group='Resistance')
lineWidth3 = input.int(2, title='', minval=1, maxval=4, inline='LineCol3', group='Resistance')

LineCol4 = input.color(color.new(#FFFFFF, 50), title='250 pip', inline='LineCol4', group='Support')
lineWidth4 = input.int(2, title='', minval=1, maxval=4, inline='LineCol4', group='Support')

LineCol5 = input.color(color.new(#f23645, 50), title='100 pip', inline='LineCol5', group='Resistance')
lineWidth5 = input.int(1, title='', minval=1, maxval=4, inline='LineCol5', group='Resistance')

LineCol6 = input.color(color.new(#4caf50, 50), title='100 pip', inline='LineCol6', group='Support')
lineWidth6 = input.int(1, title='', minval=1, maxval=4, inline='LineCol6', group='Support')

LineCol7 = input.color(color.new(#f23645, 50), title='25 pip', inline='LineCol7', group='Resistance')
lineWidth7 = input.int(1, title='', minval=1, maxval=4, inline='LineCol7', group='Resistance')

LineCol8 = input.color(color.new(#4caf50, 50), title='25 pip', inline='LineCol8', group='Support')
lineWidth8 = input.int(1, title='', minval=1, maxval=4, inline='LineCol8', group='Support')

ll_offset = timenow + math.round(ta.change(time) * 40)
ll_offset2 = timenow + math.round(ta.change(time) * 30)
ll_offset3 = timenow + math.round(ta.change(time) * 20)
ll_offset4 = timenow + math.round(ta.change(time) * 10)

if barstate.islast
    for counter = 0 to largeLines - 1 by 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=LineCol, width=lineWidth, style=resistanceStyle)
        label.new(ll_offset, stepUp, 'MW' , xloc.bar_time, yloc.price, color.white, label.style_none, LineCol, tooltip = 'Major Whole')
        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=LineCol2, width=lineWidth2, style=supportStyle)
        label.new(ll_offset, stepDown, 'MW' , xloc.bar_time, yloc.price, color.white, label.style_none, LineCol2, tooltip = 'Major Whole')

if barstate.islast
    for counter = 0 to majorLines - 1 by 1
        stepUp = math.ceil(close / majorStep) * majorStep + counter * majorStep
        line.new(bar_index, stepUp, bar_index - 1, stepUp, xloc=xloc.bar_index, extend=extend.both, color=LineCol3, width=lineWidth3, style=resistanceStyle)
        label.new(ll_offset2, stepUp, 'MQ' , xloc.bar_time, yloc.price, color.white, label.style_none, LineCol3, tooltip = 'Major Quarter')
        stepDown = math.floor(close / majorStep) * majorStep - counter * majorStep
        line.new(bar_index, stepDown, bar_index - 1, stepDown, xloc=xloc.bar_index, extend=extend.both, color=LineCol4, width=lineWidth4, style=supportStyle)
        label.new(ll_offset2, stepDown, 'MQ' , xloc.bar_time, yloc.price, color.white, label.style_none, LineCol4, tooltip = 'Major Quarter')

if barstate.islast and timeframe.isintraday
    for counter = 0 to picoLines - 1 by 1
        stepUp = math.ceil(close / picoStep) * picoStep + counter * picoStep
        line.new(bar_index, stepUp, bar_index - 1, stepUp, xloc=xloc.bar_index, extend=extend.both, color=LineCol5, width=lineWidth5, style=resistanceStyle)
        label.new(ll_offset3, stepUp, '100' , xloc.bar_time, yloc.price, color.white, label.style_none, LineCol5, tooltip = 'Minor Whole')
        stepDown = math.floor(close / picoStep) * picoStep - counter * picoStep
        line.new(bar_index, stepDown, bar_index - 1, stepDown, xloc=xloc.bar_index, extend=extend.both, color=LineCol6, width=lineWidth6, style=supportStyle)
        label.new(ll_offset3, stepDown, '100' , xloc.bar_time, yloc.price, color.white, label.style_none, LineCol6, tooltip = 'Minor Whole')

if barstate.islast and timeframe.isminutes
    for counter = 0 to femtoLines - 1 by 1
        stepUp = math.ceil(close / FemtoStep) * FemtoStep + counter * FemtoStep
        line.new(bar_index, stepUp, bar_index - 1, stepUp, xloc=xloc.bar_index, extend=extend.both, color=LineCol7, width=lineWidth7, style=resistanceStyle)
        label.new(ll_offset4, stepUp, '25' , xloc.bar_time, yloc.price, color.white, label.style_none, LineCol7, tooltip = 'Minor quarter')
        stepDown = math.floor(close / FemtoStep) * FemtoStep - counter * FemtoStep
        line.new(bar_index, stepDown, bar_index - 1, stepDown, xloc=xloc.bar_index, extend=extend.both, color=LineCol8, width=lineWidth8, style=supportStyle)
        label.new(ll_offset4, stepDown, '25' , xloc.bar_time, yloc.price, color.white, label.style_none, LineCol8, tooltip = 'Minor quarter')


