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.
受保護腳本
此腳本以閉源形式發佈。 不過,您可以自由且不受任何限制地使用它 — 在此處了解更多資訊。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
受保護腳本
此腳本以閉源形式發佈。 不過,您可以自由且不受任何限制地使用它 — 在此處了解更多資訊。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。