OPEN-SOURCE SCRIPT
Aggiornato

Structure Break + Confirmation (First Signal Only)

3 300
Swing Detection:

A Swing High is detected when the high of the central candle (based on a lookback period) is greater than the highs of the candles before and after.

A Swing Low is detected when the low of the central candle is lower than the lows of the candles before and after.

Break of Structure (BOS):

A BOS Up is confirmed when a candle closes above the most recent swing high (with a body close).

A BOS Down is confirmed when a candle closes below the most recent swing low.

Confirmation (CONF):

A CONF Up is triggered when price makes a new high after a BOS Up.

A CONF Down is triggered when price makes a new low after a BOS Down.

Only the first confirmation after a BOS is plotted.

Visuals:

Cross marks (×) are plotted at swing points.

BOS signals are shown with green (up) and red (down) labels.

CONF signals are shown with lime (up) and orange (down) triangle markers.

Dotted lines are drawn at the levels of broken swing highs/lows.
Note di rilascio
✅ Changes Summary
1. Added alertcondition() for BOS signals:
Two new alert conditions have been added to allow triggering TradingView alerts when BOS occurs:

pinescript
Копировать
Редактировать
alertcondition(bosUp, title="BOS Вгору", message="Break of Structure (вгору)")
alertcondition(bosDown, title="BOS Вниз", message="Break of Structure (вниз)")
These allow you to create alerts for:

BOS Up: when price closes above the last swing high.

BOS Down: when price closes below the last swing low.

2. No changes were made to the logic itself, except ensuring bosUp and bosDown are correctly handled and only trigger once (as originally intended in your logic using flags like bosUpPlotted and bosDownPlotted).

3. All other functionality (swing detection, BOS/CONF plotting, and line drawing) remains intact.

Now you can easily set up TradingView alerts using the condition:

"BOS Вгору" → triggers when upward BOS occurs.

"BOS Вниз" → triggers when downward BOS occurs.

Need alerts for confirmation (CONF) or want BOS to trigger multiple times? Let me know!
Note di rilascio
Feature Added:
Two persistent horizontal lines were implemented to indicate the next potential structure break levels:

One for upside breakout (at the most recent swing high).

One for downside breakout (at the most recent swing low).

How It Works:

Only one line for long and one for short is kept on the chart.

The lines update dynamically as new swing highs/lows are formed.

Old lines are automatically deleted before drawing the new ones, ensuring clarity and avoiding clutter.

Visuals:

🟢 Green dotted line → potential break upward.

🔴 Red dotted line → potential break downward.

This change improves chart readability and helps traders anticipate where the next break of structure (BOS) might occur.

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.