OPEN-SOURCE SCRIPT
Williams Fractals with Buy/Sell Signals

🧠 Concept:
This indicator is based on the concept of fractal swing highs and lows, commonly used in Bill Williams’ trading methods. A fractal forms when a candle’s high or low is higher/lower than a set number of candles on both sides. This structure helps identify local market turning points.
⚙️ Inputs:
Fractal Sensitivity (swingSensitivity):
Number of candles required on each side of the central bar to validate a fractal.
For example, if set to 2, a swing high is detected when a bar’s high is higher than the previous 2 bars and the next 2 bars.
✅ Features:
Fractal Detection:
Plots white triangles above swing highs (down fractals).
Plots white triangles below swing lows (up fractals).
Buy/Sell Signals:
Buy Signal: Triggered when the candle closes above the most recent down fractal.
Sell Signal: Triggered when the candle closes below the most recent up fractal.
Signals alternate — a Buy must follow a Sell and vice versa to reduce noise.
Signal Labels:
"BUY" label appears below the candle in green.
"SELL" label appears above the candle in red.
Alerts:
Real-time alerts are available for both Buy and Sell signals via alertcondition().
📌 Use Case:
This indicator can help you:
Detect short-term reversals.
Confirm breakouts or structure shifts.
Time entries with clear logic based on price action.
This indicator is based on the concept of fractal swing highs and lows, commonly used in Bill Williams’ trading methods. A fractal forms when a candle’s high or low is higher/lower than a set number of candles on both sides. This structure helps identify local market turning points.
⚙️ Inputs:
Fractal Sensitivity (swingSensitivity):
Number of candles required on each side of the central bar to validate a fractal.
For example, if set to 2, a swing high is detected when a bar’s high is higher than the previous 2 bars and the next 2 bars.
✅ Features:
Fractal Detection:
Plots white triangles above swing highs (down fractals).
Plots white triangles below swing lows (up fractals).
Buy/Sell Signals:
Buy Signal: Triggered when the candle closes above the most recent down fractal.
Sell Signal: Triggered when the candle closes below the most recent up fractal.
Signals alternate — a Buy must follow a Sell and vice versa to reduce noise.
Signal Labels:
"BUY" label appears below the candle in green.
"SELL" label appears above the candle in red.
Alerts:
Real-time alerts are available for both Buy and Sell signals via alertcondition().
📌 Use Case:
This indicator can help you:
Detect short-term reversals.
Confirm breakouts or structure shifts.
Time entries with clear logic based on price action.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。