OPEN-SOURCE SCRIPT
Nithin's LQ Sweep

//version=6
indicator("Liquidity Sweep Zones (HTF -> LTF)", overlay=true, max_boxes_count=200, max_labels_count=500)
// ----------------- Inputs -----------------
htf_tf = input.timeframe("240", "Structure Timeframe (HTF) - example: 240=4H")
pivot_left = input.int(3, "Pivot Left", minval=1)
pivot_right = input.int(1, "Pivot Right", minval=1)
min_wick_pts = input.float(0.0, "Min sweep wick size (points)", step=0.1)
zone_width = input.int(80, "Zone width (bars to the right)", minval=1)
show_struct = input.bool(true, "Show HTF structure level")
show_labels = input.bool(true, "Show sweep labels")
alpha_fill = input.int(78, "Zone fill transparency (0-255)", minval=0, maxval=255)
// ----------------- HTF Pivot (structure) -----------------
// request HTF pivots (these return series aligned to LTF bars)
htf_pH = request.security(syminfo.tickerid, htf_tf, ta.pivothigh(high, pivot_left, pivot_right), barmerge.gaps_off, barmerge.lookahead_off)
htf_pL = request.security(syminfo.tickerid, htf_tf, ta.pivotlow(low, pivot_left, pivot_right), barmerge.gaps_off, barmerge.lookahead_off)
// Keep latest non-na HTF pivot levels
var float lastHTFHigh = na
var float lastHTFLow = na
if not na(htf_pH)
lastHTFHigh := htf_pH
if not na(htf_pL)
lastHTFLow := htf_pL
// Optional: draw HTF levels as lines
var line htfHighLine = na
var line htfLowLine = na
if show_struct
if not na(lastHTFHigh)
if not na(htfHighLine)
line.set_xy1(htfHighLine, bar_index - 500, lastHTFHigh)
line.set_xy2(htfHighLine, bar_index + 1, lastHTFHigh)
else
htfHighLine := line.new(bar_index - 500, lastHTFHigh, bar_index + 1, lastHTFHigh, xloc=xloc.bar_index, extend=extend.none, color=color.new(color.red, 60), width=1)
if not na(lastHTFLow)
if not na(htfLowLine)
line.set_xy1(htfLowLine, bar_index - 500, lastHTFLow)
line.set_xy2(htfLowLine, bar_index + 1, lastHTFLow)
else
htfLowLine := line.new(bar_index - 500, lastHTFLow, bar_index + 1, lastHTFLow, xloc=xloc.bar_index, extend=extend.none, color=color.new(color.green, 70), width=1)
// ----------------- Sweep detection (on current timeframe) -----------------
high_sweep = false
low_sweep = false
// High sweep: price makes a wick above last HTF high, but closes back below that HTF level
if not na(lastHTFHigh)
high_sweep := (high > lastHTFHigh) and (close < lastHTFHigh) and (high - lastHTFHigh >= min_wick_pts)
// Low sweep: price makes a wick below last HTF low, but closes back above that HTF level
if not na(lastHTFLow)
low_sweep := (low < lastHTFLow) and (close > lastHTFLow) and (lastHTFLow - low >= min_wick_pts)
// ----------------- Create red zone rectangles -----------------
var array<box> boxes = array.new<box>()
// Function to create a box and push to array; removes oldest if > max
f_newBox(_x1, _y1, _x2, _y2, _fillColor, _borderColor) =>
b = box.new(_x1, _y1, _x2, _y2, xloc=xloc.bar_index, border_width=1, bgcolor=_fillColor, border_color=_borderColor)
array.push(boxes, b)
// keep reasonable number of boxes
maxBoxes = 200
if array.size(boxes) > maxBoxes
old = array.shift(boxes)
box.delete(old)
b
if high_sweep
topY = math.max(high, lastHTFHigh)
bottomY = lastHTFHigh
// create box from the HTF level to the wick high
col = color.new(color.red, alpha_fill)
bord = color.new(color.red, 40)
f_newBox(bar_index - 0, topY, bar_index + zone_width, bottomY, col, bord)
if show_labels
label.new(bar_index, high, "High Sweep", style=label.style_label_down, textcolor=color.white, color=color.new(color.red, 0), size=size.tiny)
if low_sweep
bottomY = math.min(low, lastHTFLow)
topY = lastHTFLow
col = color.new(color.red, alpha_fill) // same red fill as screenshot-red zones
bord = color.new(color.red, 40)
f_newBox(bar_index - 0, topY, bar_index + zone_width, bottomY, col, bord)
if show_labels
label.new(bar_index, low, "Low Sweep", style=label.style_label_up, textcolor=color.white, color=color.new(color.red, 0), size=size.tiny)
// Visual sweep markers (optional small shapes)
plotshape(high_sweep, title="High Sweep marker", style=shape.triangledown, location=location.abovebar, size=size.tiny, color=color.red)
plotshape(low_sweep, title="Low Sweep marker", style=shape.triangleup, location=location.belowbar, size=size.tiny, color=color.red)
// ----------------- Info panel -----------------
var table info = table.new(position.top_right, 1, 1)
if barstate.islast
table.cell(info, 0, 0, "HTF: " + htf_tf + " | Pivot L/R: " + str.tostring(pivot_left) + "/" + str.tostring(pivot_right), text_color=color.white, bgcolor=color.new(color.blue, 85))
indicator("Liquidity Sweep Zones (HTF -> LTF)", overlay=true, max_boxes_count=200, max_labels_count=500)
// ----------------- Inputs -----------------
htf_tf = input.timeframe("240", "Structure Timeframe (HTF) - example: 240=4H")
pivot_left = input.int(3, "Pivot Left", minval=1)
pivot_right = input.int(1, "Pivot Right", minval=1)
min_wick_pts = input.float(0.0, "Min sweep wick size (points)", step=0.1)
zone_width = input.int(80, "Zone width (bars to the right)", minval=1)
show_struct = input.bool(true, "Show HTF structure level")
show_labels = input.bool(true, "Show sweep labels")
alpha_fill = input.int(78, "Zone fill transparency (0-255)", minval=0, maxval=255)
// ----------------- HTF Pivot (structure) -----------------
// request HTF pivots (these return series aligned to LTF bars)
htf_pH = request.security(syminfo.tickerid, htf_tf, ta.pivothigh(high, pivot_left, pivot_right), barmerge.gaps_off, barmerge.lookahead_off)
htf_pL = request.security(syminfo.tickerid, htf_tf, ta.pivotlow(low, pivot_left, pivot_right), barmerge.gaps_off, barmerge.lookahead_off)
// Keep latest non-na HTF pivot levels
var float lastHTFHigh = na
var float lastHTFLow = na
if not na(htf_pH)
lastHTFHigh := htf_pH
if not na(htf_pL)
lastHTFLow := htf_pL
// Optional: draw HTF levels as lines
var line htfHighLine = na
var line htfLowLine = na
if show_struct
if not na(lastHTFHigh)
if not na(htfHighLine)
line.set_xy1(htfHighLine, bar_index - 500, lastHTFHigh)
line.set_xy2(htfHighLine, bar_index + 1, lastHTFHigh)
else
htfHighLine := line.new(bar_index - 500, lastHTFHigh, bar_index + 1, lastHTFHigh, xloc=xloc.bar_index, extend=extend.none, color=color.new(color.red, 60), width=1)
if not na(lastHTFLow)
if not na(htfLowLine)
line.set_xy1(htfLowLine, bar_index - 500, lastHTFLow)
line.set_xy2(htfLowLine, bar_index + 1, lastHTFLow)
else
htfLowLine := line.new(bar_index - 500, lastHTFLow, bar_index + 1, lastHTFLow, xloc=xloc.bar_index, extend=extend.none, color=color.new(color.green, 70), width=1)
// ----------------- Sweep detection (on current timeframe) -----------------
high_sweep = false
low_sweep = false
// High sweep: price makes a wick above last HTF high, but closes back below that HTF level
if not na(lastHTFHigh)
high_sweep := (high > lastHTFHigh) and (close < lastHTFHigh) and (high - lastHTFHigh >= min_wick_pts)
// Low sweep: price makes a wick below last HTF low, but closes back above that HTF level
if not na(lastHTFLow)
low_sweep := (low < lastHTFLow) and (close > lastHTFLow) and (lastHTFLow - low >= min_wick_pts)
// ----------------- Create red zone rectangles -----------------
var array<box> boxes = array.new<box>()
// Function to create a box and push to array; removes oldest if > max
f_newBox(_x1, _y1, _x2, _y2, _fillColor, _borderColor) =>
b = box.new(_x1, _y1, _x2, _y2, xloc=xloc.bar_index, border_width=1, bgcolor=_fillColor, border_color=_borderColor)
array.push(boxes, b)
// keep reasonable number of boxes
maxBoxes = 200
if array.size(boxes) > maxBoxes
old = array.shift(boxes)
box.delete(old)
b
if high_sweep
topY = math.max(high, lastHTFHigh)
bottomY = lastHTFHigh
// create box from the HTF level to the wick high
col = color.new(color.red, alpha_fill)
bord = color.new(color.red, 40)
f_newBox(bar_index - 0, topY, bar_index + zone_width, bottomY, col, bord)
if show_labels
label.new(bar_index, high, "High Sweep", style=label.style_label_down, textcolor=color.white, color=color.new(color.red, 0), size=size.tiny)
if low_sweep
bottomY = math.min(low, lastHTFLow)
topY = lastHTFLow
col = color.new(color.red, alpha_fill) // same red fill as screenshot-red zones
bord = color.new(color.red, 40)
f_newBox(bar_index - 0, topY, bar_index + zone_width, bottomY, col, bord)
if show_labels
label.new(bar_index, low, "Low Sweep", style=label.style_label_up, textcolor=color.white, color=color.new(color.red, 0), size=size.tiny)
// Visual sweep markers (optional small shapes)
plotshape(high_sweep, title="High Sweep marker", style=shape.triangledown, location=location.abovebar, size=size.tiny, color=color.red)
plotshape(low_sweep, title="Low Sweep marker", style=shape.triangleup, location=location.belowbar, size=size.tiny, color=color.red)
// ----------------- Info panel -----------------
var table info = table.new(position.top_right, 1, 1)
if barstate.islast
table.cell(info, 0, 0, "HTF: " + htf_tf + " | Pivot L/R: " + str.tostring(pivot_left) + "/" + str.tostring(pivot_right), text_color=color.white, bgcolor=color.new(color.blue, 85))
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.