PROTECTED SOURCE SCRIPT

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

40
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.

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.