OPEN-SOURCE SCRIPT
Market Structure [TFO]

📊 Market Structure [TFO] — Pine Script Indicator
Author: © tradeforopp
License: Mozilla Public License 2.0
Platform: TradingView
Type: Market structure analyzer (BOS/MSS, swings, bar color)
🧠 What It Does:
This indicator automatically identifies market structure shifts (MSS) and breaks of structure (BOS) based on pivot highs and lows. It detects when price violates previous swing points and visually marks the shift between bullish and bearish phases.
🔍 Key Features:
Swing Detection:
Uses pivot_strength to determine significant swing highs and lows.
Swings are tracked using a custom swing structure with index and value.
MSS & BOS Logic:
A Market Structure Shift (MSS) occurs when price changes direction (e.g., bullish to bearish).
A Break of Structure (BOS) happens when the price breaks the previous swing without changing trend direction.
Visual Markers:
Labels on chart showing MSS or BOS at break levels.
Optional pivot markers as small triangle shapes at swing points.
Dashed/solid/dotted lines between the break point and current candle.
Bar Coloring:
Turns candles green for bullish breaks, red for bearish breaks.
Controlled via the “Show Bar Colors” setting.
Alerts:
Alert conditions for all MSS/BOS events.
Can be used for automation or signals in TradingView.
⚙️ User Inputs:
Pivot Strength – How many candles left/right to confirm a high/low.
Show Pivots – Enables small triangle markers.
Show BOS/MSS – Toggles structure break visuals and labels.
Line Style – Customizes BOS/MSS line appearance.
Bar Colors – Enables green/red candle coloring on structure changes.
🧩 Use Cases:
Track structural shifts in real time on any asset.
Build smart money concept (SMC) strategies.
Filter entries/exits based on trend changes.
Combine with liquidity or volume-based tools for confirmation.
Author: © tradeforopp
License: Mozilla Public License 2.0
Platform: TradingView
Type: Market structure analyzer (BOS/MSS, swings, bar color)
🧠 What It Does:
This indicator automatically identifies market structure shifts (MSS) and breaks of structure (BOS) based on pivot highs and lows. It detects when price violates previous swing points and visually marks the shift between bullish and bearish phases.
🔍 Key Features:
Swing Detection:
Uses pivot_strength to determine significant swing highs and lows.
Swings are tracked using a custom swing structure with index and value.
MSS & BOS Logic:
A Market Structure Shift (MSS) occurs when price changes direction (e.g., bullish to bearish).
A Break of Structure (BOS) happens when the price breaks the previous swing without changing trend direction.
Visual Markers:
Labels on chart showing MSS or BOS at break levels.
Optional pivot markers as small triangle shapes at swing points.
Dashed/solid/dotted lines between the break point and current candle.
Bar Coloring:
Turns candles green for bullish breaks, red for bearish breaks.
Controlled via the “Show Bar Colors” setting.
Alerts:
Alert conditions for all MSS/BOS events.
Can be used for automation or signals in TradingView.
⚙️ User Inputs:
Pivot Strength – How many candles left/right to confirm a high/low.
Show Pivots – Enables small triangle markers.
Show BOS/MSS – Toggles structure break visuals and labels.
Line Style – Customizes BOS/MSS line appearance.
Bar Colors – Enables green/red candle coloring on structure changes.
🧩 Use Cases:
Track structural shifts in real time on any asset.
Build smart money concept (SMC) strategies.
Filter entries/exits based on trend changes.
Combine with liquidity or volume-based tools for confirmation.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。