Audit your true annual fee leak in 10 seconds, then grab our free Whale-vs-Retail crowding radar, 4-AI cross-market votes (BTC, Gold, Silver, NVDA), and open-source TradingView script.
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © OldK_QuantLab
//@version=6
indicator("OldK Liquidity Sweep & ATR Hard-Stop Guard [Open Source]", shorttitle="OldK Sweep Guard", overlay=true, max_labels_count=200, max_lines_count=100)
// ============================================================================
// 1. INPUTS — Zero-Repaint Structural Sweep + Anti-Wick Hard Stop + Fee HUD
// ============================================================================
grpStruct = "1. Liquidity Sweep Engine (Non-Repainting)"
swingLen = input.int(20, "Rolling Liquidity Lookback (Bars)", minval=5, maxval=100, group=grpStruct)
volMult = input.float(1.25, "Min Volume Spike Multiplier (vs SMA20)", minval=0.5, maxval=5.0, step=0.05, group=grpStruct)
showZones = input.bool(true, "Plot Rolling Liquidity Rails (High / Low)", group=grpStruct)
grpStop = "2. ATR Anti-Wick Hard-Stop Rails"
atrLen = input.int(14, "ATR Period", minval=5, maxval=50, group=grpStop)
atrMult = input.float(2.2, "Anti-Wick Hard-Stop Multiplier", minval=1.0, maxval=6.0, step=0.1, group=grpStop)
showStops = input.bool(true, "Show Structural Hard-Stop Rails", group=grpStop)
grpFee = "3. Real-Time Fee Leak Audit HUD (VIP0 Benchmark)"
showHud = input.bool(true, "Show Annual Fee Audit Table", group=grpFee)
acctUsd = input.float(1000.0, "Account Margin (USDT)", minval=50.0, step=100.0, group=grpFee)
avgLev = input.float(5.0, "Average Leverage (x)", minval=1.0, maxval=50.0, step=1.0, group=grpFee)
wkTrades = input.int(5, "Round-Trip Trades / Week", minval=1, maxval=100, group=grpFee)
takerBps = input.float(5.0, "Taker Fee (bps, 5.0 = 0.05%)", minval=0.5, maxval=20.0, step=0.5, group=grpFee)
makerBps = input.float(2.0, "Maker Fee (bps, 2.0 = 0.02%)", minval=0.0, maxval=10.0, step=0.5, group=grpFee)
// ============================================================================
// 2. LIQUIDITY SWEEP DETECTION (Strictly Confirmed Bar Close — Zero Repaint)
// ============================================================================
priorHigh = ta.highest(high[1], swingLen)
priorLow = ta.lowest(low[1], swingLen)
volSma = ta.sma(volume, 20)
volSpike = na(volSma) or volSma <= 0 ? true : (volume >= volSma * volMult)
// Bearish Liquidity Sweep: wicks above rolling liquidity high, fails and closes back inside
bearSweepRaw = high > priorHigh and close < priorHigh and close < open and volSpike
// Bullish Liquidity Sweep: wicks below rolling liquidity low, reclaims and closes back inside
bullSweepRaw = low < priorLow and close > priorLow and close > open and volSpike
bearSweep = bearSweepRaw and barstate.isconfirmed
bullSweep = bullSweepRaw and barstate.isconfirmed
// ============================================================================
// 3. STRUCTURAL ATR ANTI-WICK HARD-STOP RAILS
// ============================================================================
atrVal = ta.atr(atrLen)
emaTrend = ta.ema(close, 50)
isBullBias = close >= emaTrend
shortStopLine = priorHigh + atrVal * atrMult * 0.5
longStopLine = priorLow - atrVal * atrMult * 0.5
// ============================================================================
// 4. VISUAL PLOTS (Clean Institutional High-Contrast Dark Palette)
// ============================================================================
colGreen = color.rgb(0, 229, 153)
colRed = color.rgb(255, 59, 78)
colGold = color.rgb(223, 192, 127)
colMute = color.rgb(100, 116, 139)
plot(showZones ? priorHigh : na, "Liquidity Ceiling", color=color.new(colRed, 55), linewidth=1, style=plot.style_stepline)
plot(showZones ? priorLow : na, "Liquidity Floor", color=color.new(colGreen, 55), linewidth=1, style=plot.style_stepline)
plot(showStops ? shortStopLine : na, "Short Hard-Stop Rail", color=color.new(colGold, 25), linewidth=2, style=plot.style_linebr)
plot(showStops ? longStopLine : na, "Long Hard-Stop Rail", color=color.new(colGold, 25), linewidth=2, style=plot.style_linebr)
plotshape(bearSweep, title="Bearish Sweep (Stop Hunt Above)", style=shape.triangledown, location=location.abovebar, color=colRed, size=size.small, text="SWEEP", textcolor=colRed)
plotshape(bullSweep, title="Bullish Sweep (Stop Hunt Below)", style=shape.triangleup, location=location.belowbar, color=colGreen, size=size.small, text="SWEEP", textcolor=colGreen)
// ============================================================================
// 5. ANNUAL FEE LEAK AUDIT HUD (Helps Traders Audit Taker vs Maker Drag)
// ============================================================================
var table hud = table.new(position.top_right, 2, 5, bgcolor=color.rgb(11, 15, 23, 88), border_color=color.rgb(223, 192, 127, 45), border_width=1)
if showHud and barstate.islast
annualVol = acctUsd * avgLev * wkTrades * 2.0 * 52.0
annualTaker = annualVol * (takerBps / 10000.0)
annualMaker = annualVol * (makerBps / 10000.0)
annualSave = math.max(0.0, annualTaker - annualMaker)
regimeStr = isBullBias ? "ABOVE EMA50 (BULL)" : "BELOW EMA50 (BEAR)"
regimeCol = isBullBias ? colGreen : colRed
table.cell(hud, 0, 0, "OLDK SWEEP & FEE GUARD", text_color=colGold, text_size=size.small, text_halign=text.align_left)
table.cell(hud, 1, 0, regimeStr, text_color=regimeCol, text_size=size.small, text_halign=text.align_right)
table.cell(hud, 0, 1, "Annual Taker Fee Burn", text_color=color.white, text_size=size.small, text_halign=text.align_left)
table.cell(hud, 1, 1, "-$" + str.tostring(math.round(annualTaker), "#,###") + "/yr", text_color=colRed, text_size=size.small, text_halign=text.align_right)
table.cell(hud, 0, 2, "Saved via Maker Limits", text_color=color.white, text_size=size.small, text_halign=text.align_left)
table.cell(hud, 1, 2, "+$" + str.tostring(math.round(annualSave), "#,###") + "/yr", text_color=colGreen, text_size=size.small, text_halign=text.align_right)
table.cell(hud, 0, 3, "Short Invalidation Rail", text_color=colMute, text_size=size.tiny, text_halign=text.align_left)
table.cell(hud, 1, 3, str.tostring(shortStopLine, format.mintick), text_color=colGold, text_size=size.tiny, text_halign=text.align_right)
table.cell(hud, 0, 4, "Long Invalidation Rail", text_color=colMute, text_size=size.tiny, text_halign=text.align_left)
table.cell(hud, 1, 4, str.tostring(longStopLine, format.mintick), text_color=colGold, text_size=size.tiny, text_halign=text.align_right)
// ============================================================================
// 6. ALERTS (Webhook / App Push Ready)
// ============================================================================
alertcondition(bearSweep, title="Bearish Liquidity Sweep", message="OldK Sweep Guard: Bearish liquidity sweep confirmed on {{ticker}} ({{interval}}) at {{close}}")
alertcondition(bullSweep, title="Bullish Liquidity Sweep", message="OldK Sweep Guard: Bullish liquidity sweep confirmed on {{ticker}} ({{interval}}) at {{close}}")
OLDKLIVE receive an automatic 20% fee rebate while we earn a partner commission from exchange fees. Derivatives carry high risk; all tools are educational telemetry, not financial advice.