OPEN-SOURCE SCRIPT
Macro Gann Swing with BOS (P, T & BOS)

Macro Gann Swing & Break of Structure (BOS) [v6]
The Macro Gann Swing & Break of Structure (BOS) indicator maps out true institutional market structure by removing market chop and intraday noise.
Instead of cluttering your screen with dozens of minor pivot points, this script uses a depth-based macro filter to identify significant market turning points (Peaks & Troughs), connect them with clean swing lines, and automatically print Break of Structure (BOS) levels when key structure breaks.
Key Features:
Macro Peak (𝗣) & Trough (𝗧) Detection: Filters out lower highs and higher lows during choppy ranges. You only see major structural highs and lows.
Dynamic ZigZag Swing Lines: Connects confirmed macro peaks and troughs to give you an accurate visual map of market flow.
Automatic Break of Structure (BOS): Triggers a BOS ▲ or BOS ▼ label with a dashed level line the exact moment a candle closes beyond a prior macro Peak or Trough.
Auto-Updating Legs: Swing points and lines dynamically stretch as moves extend, keeping your chart clean and eliminating ghost lines.
Fully Customizable: Easily adjust lookback sensitivity, toggle swing lines on/off, or change colors to fit your dark or light chart themes.
How to Read the Indicator :
Uptrend Structure: Characterized by a sequence of Higher Peaks (𝗣) and Higher Troughs (𝗧).
Downtrend Structure: Characterized by a sequence of Lower Peaks (𝗣) and Lower Troughs (𝗧).
Bullish BOS : Triggered when price closes above the active macro Peak (𝗣), signaling trend continuation or a bullish shift.
Bearish BOS : Triggered when price closes below the active macro Trough (𝗧), signaling trend continuation or a bearish shift.
How to Tune the Settings
Macro Swing Depth (Bar Lookback)
Higher Values (20–30): Best for zoomed-out views and higher timeframes. Completely wipes out market noise and leaves only macro structure.
Lower Values (10–15): Best for scalping or lower timeframes (1m–5m) where you want to catch smaller intraday swing legs.
ideal for :
Smart Money Concepts (SMC) & ICT Traders looking for clean market structure mapping.
Price Action & Trend Traders who want to trade breaks of structure without chart clutter.
Breakout Traders looking for clear confirmation of structural continuation.
The Macro Gann Swing & Break of Structure (BOS) indicator maps out true institutional market structure by removing market chop and intraday noise.
Instead of cluttering your screen with dozens of minor pivot points, this script uses a depth-based macro filter to identify significant market turning points (Peaks & Troughs), connect them with clean swing lines, and automatically print Break of Structure (BOS) levels when key structure breaks.
Key Features:
Macro Peak (𝗣) & Trough (𝗧) Detection: Filters out lower highs and higher lows during choppy ranges. You only see major structural highs and lows.
Dynamic ZigZag Swing Lines: Connects confirmed macro peaks and troughs to give you an accurate visual map of market flow.
Automatic Break of Structure (BOS): Triggers a BOS ▲ or BOS ▼ label with a dashed level line the exact moment a candle closes beyond a prior macro Peak or Trough.
Auto-Updating Legs: Swing points and lines dynamically stretch as moves extend, keeping your chart clean and eliminating ghost lines.
Fully Customizable: Easily adjust lookback sensitivity, toggle swing lines on/off, or change colors to fit your dark or light chart themes.
How to Read the Indicator :
Uptrend Structure: Characterized by a sequence of Higher Peaks (𝗣) and Higher Troughs (𝗧).
Downtrend Structure: Characterized by a sequence of Lower Peaks (𝗣) and Lower Troughs (𝗧).
Bullish BOS : Triggered when price closes above the active macro Peak (𝗣), signaling trend continuation or a bullish shift.
Bearish BOS : Triggered when price closes below the active macro Trough (𝗧), signaling trend continuation or a bearish shift.
How to Tune the Settings
Macro Swing Depth (Bar Lookback)
Higher Values (20–30): Best for zoomed-out views and higher timeframes. Completely wipes out market noise and leaves only macro structure.
Lower Values (10–15): Best for scalping or lower timeframes (1m–5m) where you want to catch smaller intraday swing legs.
ideal for :
Smart Money Concepts (SMC) & ICT Traders looking for clean market structure mapping.
Price Action & Trend Traders who want to trade breaks of structure without chart clutter.
Breakout Traders looking for clear confirmation of structural continuation.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.