Bank Levels - Psychological Levels - Bitcoin, Indices, Forex
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © cryptomachine2

//@version=4
study("Bank Levels", overlay=true)

var levels = input(5, title="Number of levels", type=input.integer)
var lineColor = input(color.white, "Line color", type=input.color)
var lineWidth = input(1, title="Line width", type=input.integer)

var spacing = if syminfo.ticker == 'XAUUSD'
    25000
else if syminfo.ticker == 'SPX500USD'
    500
else if syminfo.ticker == 'NAS100USD'
    2500
else if syminfo.ticker == 'US30USD'
    2500
else if syminfo.ticker == 'BTCUSDT'
    500000
else if syminfo.type == 'crypto'
    500
else if syminfo.type == 'forex'
    500
else
    2500


var step = syminfo.mintick * spacing
if barstate.islast
    //label.new(bar_index, low, text=syminfo.type, yloc=yloc.abovebar)
    for counter = 0 to levels - 1
        price = if syminfo.type == 'index'
            ceil(close / 4) * 4
        else 
            close
            
        stepUp = ceil(price / step) * step + (counter * step)
        stepDown = floor(price / step) * step - (counter * step)
        line.new(bar_index, stepUp, bar_index - 1, stepUp, xloc=xloc.bar_index, extend=extend.both, color=lineColor, width=lineWidth, style=line.style_dashed)
        line.new(bar_index, stepDown, bar_index - 1, stepDown, xloc=xloc.bar_index, extend=extend.both, color=lineColor, width=lineWidth, style=line.style_dashed)

