OPEN-SOURCE SCRIPT
Güncellendi Structure Break + Confirmation (First Signal Only)

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.
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.
Sürüm Notları
✅ Changes Summary1. 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!
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.