Liquidity Sweep Pro | Open Source

PROTRADER9 · study · 53 行 · 点赞 1,125 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PROTRADER9
//@version=6
indicator("Liquidity Sweep Pro | Open Source", overlay=true, max_lines_count=200, max_labels_count=200)
 
// ───── Settings ─────
pivotLen = input.int(5, "Swing Length", minval=1)
showLevels = input.bool(true, "Show Liquidity Levels")
showSignals = input.bool(true, "Show Sweep Signals")
confirmClose = input.bool(true, "Require Candle Close Confirmation")
 
// ───── Detect Swing Points ─────
pivotHigh = ta.pivothigh(high, pivotLen, pivotLen)
pivotLow  = ta.pivotlow(low, pivotLen, pivotLen)
 
var float lastHigh = na
var float lastLow = na
 
var line highLine = na
var line lowLine = na
 
if not na(pivotHigh)
    lastHigh := pivotHigh
    if showLevels
        if not na(highLine)
            line.delete(highLine)
        highLine := line.new(bar_index - pivotLen, lastHigh, bar_index, lastHigh, extend=extend.right, color=color.red, style=line.style_dashed, width=1)
 
if not na(pivotLow)
    lastLow := pivotLow
    if showLevels
        if not na(lowLine)
            line.delete(lowLine)
        lowLine := line.new(bar_index - pivotLen, lastLow, bar_index, lastLow, extend=extend.right, color=color.lime, style=line.style_dashed, width=1)
 
// ───── Liquidity Sweeps ─────
// Sweep above swing high, then close back below it
bearSweepRaw = not na(lastHigh) and high > lastHigh and close < lastHigh
 
// Sweep below swing low, then close back above it
bullSweepRaw = not na(lastLow) and low < lastLow and close > lastLow
 
bearSweep = bearSweepRaw and (not confirmClose or barstate.isconfirmed)
bullSweep = bullSweepRaw and (not confirmClose or barstate.isconfirmed)
 
// ───── Signals ─────
plotshape(showSignals and bullSweep, title="Bullish Liquidity Sweep", text="BULL SWEEP", style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white, size=size.small)
 
plotshape(showSignals and bearSweep, title="Bearish Liquidity Sweep", text="BEAR SWEEP", style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white, size=size.small)
 
// ───── Alerts ─────
alertcondition(bullSweep, title="Bullish Liquidity Sweep", message="Bullish liquidity sweep on {{ticker}} | Close: {{close}}")
alertcondition(bearSweep, title="Bearish Liquidity Sweep", message="Bearish liquidity sweep on {{ticker}} | Close: {{close}}")

← 返回列表