OPEN-SOURCE SCRIPT
Sweep + BOS (Lines + First Confirmed Only)

🔍 Indicator: Sweep + BOS (Break of Structure with Visual Lines)
🧠 Overview
This indicator combines Swing detection, Liquidity Sweeps, and Break of Structure (BOS) logic, with:
Customizable swing length,
BOS signals only after confirmed sweeps,
BOS shown only once per sweep,
Visual labels and connecting lines to highlight structure breaks clearly.
⚙️ Inputs
Swing Length:
Defines how many candles to use to identify a swing high/low. Must be an odd number (e.g., 3, 5, 7...).
Sweep Lookback Window:
Sets how far back the script checks for a sweep (false breakout over a swing).
BOS Validity After Sweep:
Number of bars within which a BOS can be considered valid after a sweep.
Toggle Options:
Show/hide:
Swing Labels
Sweep Labels
BOS Labels
BOS Connecting Lines
📌 Logic Breakdown
✅ Swings
Swing High: A candle’s high is greater than the highs of all N candles on both sides.
Swing Low: A candle’s low is lower than the lows of all N candles on both sides.
💧 Liquidity Sweeps
Sweep High:
Price spikes above a previous Swing High,
Then closes back below it (false breakout).
Sweep Low:
Price drops below a previous Swing Low,
Then closes back above it.
🔁 Break of Structure (BOS)
A BOS is only shown if:
It occurs after a valid sweep (within X bars),
It hasn’t been already plotted for that sweep,
BOS ↑ is only possible after Sweep Low,
BOS ↓ is only possible after Sweep High,
Opposite BOS type resets the last BOS state.
BOS ↑ (Bullish):
Confirmed when price closes above previous Swing High after Sweep Low.
Label appears at the candle low.
A line is drawn from the Swing Low to the BOS candle.
BOS ↓ (Bearish):
Confirmed when price closes below previous Swing Low after Sweep High.
Label appears at the candle high.
A line is drawn from the Swing High to the BOS candle.
🧠 Overview
This indicator combines Swing detection, Liquidity Sweeps, and Break of Structure (BOS) logic, with:
Customizable swing length,
BOS signals only after confirmed sweeps,
BOS shown only once per sweep,
Visual labels and connecting lines to highlight structure breaks clearly.
⚙️ Inputs
Swing Length:
Defines how many candles to use to identify a swing high/low. Must be an odd number (e.g., 3, 5, 7...).
Sweep Lookback Window:
Sets how far back the script checks for a sweep (false breakout over a swing).
BOS Validity After Sweep:
Number of bars within which a BOS can be considered valid after a sweep.
Toggle Options:
Show/hide:
Swing Labels
Sweep Labels
BOS Labels
BOS Connecting Lines
📌 Logic Breakdown
✅ Swings
Swing High: A candle’s high is greater than the highs of all N candles on both sides.
Swing Low: A candle’s low is lower than the lows of all N candles on both sides.
💧 Liquidity Sweeps
Sweep High:
Price spikes above a previous Swing High,
Then closes back below it (false breakout).
Sweep Low:
Price drops below a previous Swing Low,
Then closes back above it.
🔁 Break of Structure (BOS)
A BOS is only shown if:
It occurs after a valid sweep (within X bars),
It hasn’t been already plotted for that sweep,
BOS ↑ is only possible after Sweep Low,
BOS ↓ is only possible after Sweep High,
Opposite BOS type resets the last BOS state.
BOS ↑ (Bullish):
Confirmed when price closes above previous Swing High after Sweep Low.
Label appears at the candle low.
A line is drawn from the Swing Low to the BOS candle.
BOS ↓ (Bearish):
Confirmed when price closes below previous Swing Low after Sweep High.
Label appears at the candle high.
A line is drawn from the Swing High to the BOS candle.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。