//@version=6 indicator("Order Blocks Volume Delta 3D | Flux Charts", overlay = true, max_boxes_count = 500, max_labels_count = 500, max_lines_count = 500, max_polylines_count = 100, max_bars_back = 5000) //#region CONSTANTS // Core constants that control stored OB capacity and label size. const int MAX_STORED_OBS = 50 const int retestSize = 4 //#endregion //#region INPUTS // Core user controls for OB behavior, volume delta, 3D style and alerts. grpOB = "ORDER BLOCKS" swingLen = input.int(5, "Swing Length", minval = 1, group = grpOB, inline = "sw", display = display.none) bullObColor = input.color(color.new(color.teal, 55), "", group = grpOB, inline = "sw") bearObColor = input.color(color.new(color.red, 55), "", group = grpOB, inline = "sw") invMethod = input.string("Wick", "Invalidation", options = ["Wick", "Close"], group = grpOB, display = display.none) showNearestX = input.int(3, "Show Nearest", minval = 1, maxval = 20, group = grpOB, display = display.none) extendZones = input.int(10, "Extend Zones", minval = 0, group = grpOB, tooltip = "This will extend the zones by X candles.", display = display.none) showRetestLbl = input.bool(true, "Retest Labels", group = grpOB, inline = "tog") hideInvalid = input.bool(true, "Hide Invalidated Zones", group = grpOB, inline = "tog") grpVD = "VOLUME DELTA" vdEnable = input.bool(true, "Enable", group = grpVD, inline = "vd") vdBullColor = input.color(color.new(color.teal, 65), "", group = grpVD, inline = "vd") vdBearColor = input.color(color.new(color.red, 65), "", group = grpVD, inline = "vd") vd3D = input.bool(true, "3D", group = grpVD, inline = "3d", tooltip = "Adds 3D-style depth faces.") and vdEnable vd3DDepth = input.int(5, "", group = grpVD, inline = "3d", minval = 1, maxval = 5, display = display.none) displayStyle = input.string("Vertical", "Display Style", options = ["Vertical", "Horizontal"], group = grpVD, tooltip = "Horizontal: split shown top/bottom.\nVertical: split shown left/right across the zone.", display = display.none) vdTfIn = input.timeframe("", "Volume Delta Timeframe", group = grpVD, tooltip = "Lower timeframe used to estimate delta") showTotalVol = input.bool(true, "Display Total Volume", group = grpVD, tooltip = "Displays total volume (Bull+Bear) from the active delta source.", inline = "vd2") and vdEnable showDeltaPct = input.bool(true, "Show Delta %", group = grpVD, inline = "vd2", tooltip = "Shows bullish vs bearish volume split.\nIf selected TF is lower than chart TF, uses LTF data; otherwise uses chart TF.") and vdEnable vdTextColor = input.color(color.white, "", group = grpVD, inline = "vd2") grpAL = "ALERTS" alBullOB = input.bool(true, "Bullish Order Block", group = grpAL, inline = "oba") alBearOB = input.bool(true, "Bearish Order Block", group = grpAL, inline = "oba") alBullRetest = input.bool(true, "Bullish OB Retest", group = grpAL, inline = "obr") alBearRetest = input.bool(true, "Bearish OB Retest", group = grpAL, inline = "obr") //#endregion //#region TYPES // Custom structs for order blocks and 3D poly drawing. type PolyParams array points color lineColor color fillColor int lineWidth type ObRec int leftIndex int leftTime int createdIndex int createdTime float top float bottom bool isBull bool active bool retested int retestIndex int retestTime int invalidIndex int invalidTime float bullVol float bearVol float totalVol float bullPct float bearPct bool hasDelta type RetestRec int barIndex bool isBull int obLeftIndex int obCreatedIndex //#endregion //#region GENERIC HELPERS // Small utilities: clearing drawings, geometry helpers, nearest-OB picking. method clearAll(array bx, array pl, array