Liquidity Sweep Hunter | BUY & SELL

ReubenMiles · study · 58 行 · 点赞 74 · 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/
// © ReubenMiles
 
//@version=6
indicator("Liquidity Sweep Hunter | BUY & SELL", overlay=true)
 
// Liquidity detection
swingLength = 5
 
previousLow  = ta.lowest(low[1], swingLength)
previousHigh = ta.highest(high[1], swingLength)
 
// Sell-side liquidity sweep = BUY
bullishSweep = low < previousLow and close > previousLow
 
// Buy-side liquidity sweep = SELL
bearishSweep = high > previousHigh and close < previousHigh
 
// Prevent consecutive same-direction signals
var int lastSignal = 0
 
buySignal = bullishSweep and barstate.isconfirmed and lastSignal != 1
sellSignal = bearishSweep and barstate.isconfirmed and lastSignal != -1
 
if buySignal
    lastSignal := 1
 
if sellSignal
    lastSignal := -1
 
// BUY label
plotshape(buySignal,
     title="BUY",
     style=shape.labelup,
     location=location.belowbar,
     color=color.green,
     text="BUY",
     textcolor=color.white,
     size=size.small)
 
// SELL label
plotshape(sellSignal,
     title="SELL",
     style=shape.labeldown,
     location=location.abovebar,
     color=color.red,
     text="SELL",
     textcolor=color.white,
     size=size.small)
 
// Alerts
alertcondition(buySignal,
     title="BUY Alert",
     message="Liquidity Sweep Hunter: BUY Signal")
 
alertcondition(sellSignal,
     title="SELL Alert",
     message="Liquidity Sweep Hunter: SELL Signal")

← 返回列表