OPEN-SOURCE SCRIPT
Breakout of fractals with alternating signals

📌 Indicator Name: Break of Fractal Body (with Alternating Signals and Extended Lines)
🔍 Purpose:
This indicator detects swing highs and lows (fractals) based on candle body closes, not wicks. It then:
Confirms a breakout when the price closes beyond the body of the fractal.
Alternates signals: a "long" signal only appears after a "short", and vice versa.
Draws a horizontal line from the original fractal bar (where it formed) to the current bar where the breakout happens.
⚙️ Key Features:
✅ Fractals Based on Candle Bodies Only:
A top fractal is where the candle body is higher than len candles on both sides.
A bottom fractal is where the candle body is lower than len candles on both sides.
✅ Breakout Confirmation:
A bullish breakout is when price closes above the last top body fractal.
A bearish breakout is when price closes below the last bottom body fractal.
Breakouts are only recognized if they alternate: you won’t get multiple long/shorts in a row.
✅ Visual Elements:
🔺 Red triangle: Top body fractal.
🔻 Green triangle: Bottom body fractal.
📈 Label BUY: when price breaks a top body fractal.
📉 Label SELL: when price breaks a bottom body fractal.
➖ Horizontal line: drawn from the fractal bar to the breakout bar, showing the exact level of breakout.
✅ Alerts:
Alert when a bullish breakout occurs.
Alert when a bearish breakout occurs.
🔍 Purpose:
This indicator detects swing highs and lows (fractals) based on candle body closes, not wicks. It then:
Confirms a breakout when the price closes beyond the body of the fractal.
Alternates signals: a "long" signal only appears after a "short", and vice versa.
Draws a horizontal line from the original fractal bar (where it formed) to the current bar where the breakout happens.
⚙️ Key Features:
✅ Fractals Based on Candle Bodies Only:
A top fractal is where the candle body is higher than len candles on both sides.
A bottom fractal is where the candle body is lower than len candles on both sides.
✅ Breakout Confirmation:
A bullish breakout is when price closes above the last top body fractal.
A bearish breakout is when price closes below the last bottom body fractal.
Breakouts are only recognized if they alternate: you won’t get multiple long/shorts in a row.
✅ Visual Elements:
🔺 Red triangle: Top body fractal.
🔻 Green triangle: Bottom body fractal.
📈 Label BUY: when price breaks a top body fractal.
📉 Label SELL: when price breaks a bottom body fractal.
➖ Horizontal line: drawn from the fractal bar to the breakout bar, showing the exact level of breakout.
✅ Alerts:
Alert when a bullish breakout occurs.
Alert when a bearish breakout occurs.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.