High volume zone
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © remtradepro

//@version=5
indicator("High volume zone", overlay=true)
i_res = input.timeframe('1', "Resolution", options=['1', '3','5','10','15'])
amount = input.int(1000, "Total volume", minval=1, maxval=100000, step=1)
max = input.int(2, "Max zone display per candle", minval=1, maxval=100000, step=1)

arrVolume  = request.security_lower_tf(syminfo.tickerid, i_res, volume, false)
arrClose  = request.security_lower_tf(syminfo.tickerid, i_res, close, false)
arrOpen  = request.security_lower_tf(syminfo.tickerid, i_res, open, false)

bgColor = input.color(color.rgb(255,128,0,90), "Background Color")
borderColor = input.color(color.rgb(255,128,0,0), "Border Color")
textBgColor = input.color(color.rgb(255,128,0,100), "Text Background Color")
textColor = input.color(color.rgb(255,255,255,0), "Text Color")

var int myInc = 0

myInc := 0

arrDisplay = array.new_float(0,0)
arrDisplayClose = array.new_float(0,0)
arrDisplayOpen = array.new_float(0,0)
for index in arrVolume
    
    if index > amount
        if array.size(arrDisplay)<max
            array.push(arrDisplay, math.round(array.get(arrVolume,myInc)))
            array.push(arrDisplayClose, array.get(arrClose,myInc))
            array.push(arrDisplayOpen, array.get(arrOpen,myInc))
            box.new(left=bar_index[1], top= math.round(array.get(arrClose,myInc)), right=bar_index[0]+1, bottom=math.round(array.get(arrOpen,myInc)), bgcolor=bgColor, border_color=borderColor )

    myInc +=1

label.new(array.size(arrDisplay)>0?bar_index:na, high, "v =" + str.tostring(arrDisplay), color=textBgColor, textcolor=textColor)

