PROTECTED SOURCE SCRIPT
Пробиття фракталів з алертами (чергуються сигнали)

Key Changes Summary:
Added Signal Tracking:
Introduced a new variable lastSignal to track the previous signal ("buy", "sell", or "none" at the start).
Modified Buy/Sell Conditions:
Buy Signal (buyBreakout) now requires:
Breakout above the last top fractal (close > lastTop).
Previous signal was either "sell" or "none" (no recent BUY signal).
Sell Signal (sellBreakout) now requires:
Breakout below the last bottom fractal (close < lastBottom).
Previous signal was either "buy" or "none" (no recent SELL signal).
Dynamic Signal Updates:
Whenever a new buyBreakout occurs, lastSignal is set to "buy".
Whenever a new sellBreakout occurs, lastSignal is set to "sell".
Result:
The script now alternates signals:
A BUY signal is only generated after a SELL (or if no prior signals exist).
A SELL signal is only generated after a BUY (or if no prior signals exist).
This prevents consecutive signals of the same type (e.g., two BUYs in a row).
Visual/Alerter Impact:
The plot shapes (triangles for fractals, labels for breakouts) remain unchanged.
Alerts (alertcondition) now trigger only when signals alternate (no duplicate BUY/SELL alerts in succession).
Code Logic Flow:
Check fractal breakouts (unchanged).
Before generating a signal, verify the previous signal type (lastSignal).
Update lastSignal after a valid breakout.
This ensures cleaner, alternating trade signals that avoid repetition.
Added Signal Tracking:
Introduced a new variable lastSignal to track the previous signal ("buy", "sell", or "none" at the start).
Modified Buy/Sell Conditions:
Buy Signal (buyBreakout) now requires:
Breakout above the last top fractal (close > lastTop).
Previous signal was either "sell" or "none" (no recent BUY signal).
Sell Signal (sellBreakout) now requires:
Breakout below the last bottom fractal (close < lastBottom).
Previous signal was either "buy" or "none" (no recent SELL signal).
Dynamic Signal Updates:
Whenever a new buyBreakout occurs, lastSignal is set to "buy".
Whenever a new sellBreakout occurs, lastSignal is set to "sell".
Result:
The script now alternates signals:
A BUY signal is only generated after a SELL (or if no prior signals exist).
A SELL signal is only generated after a BUY (or if no prior signals exist).
This prevents consecutive signals of the same type (e.g., two BUYs in a row).
Visual/Alerter Impact:
The plot shapes (triangles for fractals, labels for breakouts) remain unchanged.
Alerts (alertcondition) now trigger only when signals alternate (no duplicate BUY/SELL alerts in succession).
Code Logic Flow:
Check fractal breakouts (unchanged).
Before generating a signal, verify the previous signal type (lastSignal).
Update lastSignal after a valid breakout.
This ensures cleaner, alternating trade signals that avoid repetition.
Skrip dilindungi
Skrip ini diterbitkan sebagai sumber tertutup. Akan tetapi, anda boleh menggunakannya dengan percuma dan tanpa had – ketahui lebih lanjut di sini.
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 dilindungi
Skrip ini diterbitkan sebagai sumber tertutup. Akan tetapi, anda boleh menggunakannya dengan percuma dan tanpa had – ketahui lebih lanjut di sini.
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.