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.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.