//@version=5 indicator("Simple FVG", overlay=true, max_boxes_count=500) boxLength = input.int(20, "Box Length", minval=1) deleteFilled = input.bool(true, "Delete Filled FVGs") var box[] bullBoxes = array.new_box() var box[] bearBoxes = array.new_box() // Bullish FVG bullFVG = low > high[2] // Bearish FVG bearFVG = high < low[2] if bullFVG b = box.new( left = bar_index - 2, top = low, right = bar_index + boxLength, bottom = high[2], bgcolor = color.new(color.green, 85), border_color = color.green) array.push(bullBoxes, b) if bearFVG b = box.new( left = bar_index - 2, top = low[2], right = bar_index + boxLength, bottom = high, bgcolor = color.new(color.red, 85), border_color = color.red) array.push(bearBoxes, b) // Manage bullish boxes if array.size(bullBoxes) > 0 for i = array.size(bullBoxes) - 1 to 0 bx = array.get(bullBoxes, i) if close <= box.get_bottom(bx) if deleteFilled box.delete(bx) array.remove(bullBoxes, i) // Manage bearish boxes if array.size(bearBoxes) > 0 for i = array.size(bearBoxes) - 1 to 0 bx = array.get(bearBoxes, i) if close >= box.get_top(bx) if deleteFilled box.delete(bx) array.remove(bearBoxes, i)