Gap Finder (Arpan)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © truetechlevels

//@version=5
indicator("Gap Finder (Arpan)", overlay = true, max_boxes_count = 25)

varBS = ta.barssince(dayofmonth != dayofmonth[1])

var varBlOpeningGaps = input.bool(false, "Opening Gaps On/Off")

var varBoxLength = input.int(0, "Box Length")

var varGapupBGColor = input.color(color.aqua, "Gap Up Background")
var varGapupBorderColor = input.color(color.white, "Gap Up Border")

var varGapDnBGColor = input.color(color.rgb(215, 31, 248), "Gap Down Background")
var varGapDnBorderColor = input.color(color.white, "Gap Down Border")

varBlGapUp = low > high[1] 
varBlGapDown = high < low[1]


if varBlGapUp 
    if varBlOpeningGaps==false and ( varBS > 1)
        BoxUp = box.new(bar_index-1,low,bar_index + varBoxLength,high[1], border_color = varGapupBorderColor, bgcolor = varGapupBGColor)
    else if varBlOpeningGaps
        BoxUp = box.new(bar_index-1,low,bar_index + varBoxLength,high[1], border_color = varGapupBorderColor, bgcolor = varGapupBGColor)

if varBlGapDown
    if varBlOpeningGaps==false and ( varBS > 1)
        BoxDown = box.new(bar_index-1,high,bar_index + varBoxLength,low[1], border_color = varGapDnBorderColor, bgcolor = varGapDnBGColor)
    else if varBlOpeningGaps
        BoxDown = box.new(bar_index-1,high,bar_index + varBoxLength,low[1], border_color = varGapDnBorderColor, bgcolor = varGapDnBGColor)




