OPEN-SOURCE SCRIPT
Drunken Bird

Inspiration for the support and resistance plateau lines came from AnotherDAPTrader.
The TSL Drunken Bird is an enhanced technical analysis tool for swing traders on TradingView, based on the original Accurate Swing Trading System by ceyhun. It generates buy and sell signals when price crosses a dynamic Trailing Stop Loss (TSL) level derived from recent highs and lows. This version introduces plateau detection for support and resistance lines, dynamic label expiration to reduce clutter, customizable line styles and decay, and improved HTF confluence for trend-aligned trading. Visual elements include signal labels, horizontal lines, a colored TSL plot, and optional bar/background coloring. Alerts are available for buy/sell crossovers, making it suitable for assets like NASDAQ E-mini futures, stocks, forex, and more.
This script adapts and expands upon ceyhun's original codetradingview.com, adding significant features such as tolerance-based plateau identification for support/resistance, label management with timeframe-aware expiration (~7 days), cross-count decay for lines, and expanded customization options. Inspiration for the support and resistance plateau lines came from AnotherDAPTrader. Released under the Mozilla Public License 2.0.Key
Features
Swing Signals: "BUY" and "SELL" labels on price crossovers/crossunders of the TSL, with a user-defined lookback (default 3).
HTF Confluence: Filters signals based on higher timeframe trend (e.g., "EXIT LONG" instead of "SELL" if HTF is bullish); toggleable.
HTF Options: Select from 5m, 15m, 30m, 1h, 4h, Daily, Weekly, or Monthly.
Plateau Detection: Identifies flat highs/lows (with tolerance) for resistance/support lines, plotted as dotted/solid/dashed with customizable colors, thickness, and decay after crosses (default 2).
Horizontal Lines: Green (buy) and red (sell) lines at signal closes, extending right until crossed; toggle between short (no extension limit) or long visualization.
TSL Visualization: Colored line (green if close >= TSL, red otherwise) for dynamic levels.
Bar/Background Coloring: Optional green/red coloring based on price vs. TSL.
Label Expiration: All labels (signals and plateaus) auto-delete after ~7 days (timeframe-adjusted, default 1008 bars).
Alerts: Triggers for "Buy Signal" and "Sell Signal" on crossovers.
How to Use
Add to Chart: Paste the Pine Script into TradingView's editor and add to your chart.
Configure Settings:
Swing: Lookback for highs/lows (min 1).
Plateau Tolerance: Flatness allowance (default 0.0).
Use HTF Confluence: Enable for trend filtering.
Higher Time Frame: Choose timeframe string.
Barcolor/Bgcolor: Toggle coloring.
Show Plateau Lines: Enable support/resistance.
Line Styles/Colors/Thickness: Customize buy/sell and plateau visuals.
Plateau Line Decay: Crosses before stopping extension.
Label Expiration: Bars for auto-deletion (~7 days).
Interpret Elements:
Labels: "BUY"/"SELL" (green/red), "EXIT SHORT"/"EXIT LONG" (orange) on signals; "Res"/"Sup" on plateaus.
Lines: Extend right until conditions met (cross for buy/sell, decay threshold for plateaus).
TSL Plot: Monitors trend shifts.
Set Alerts: Use "Buy Signal" or "Sell Signal" conditions for notifications.
Testing: Apply to volatile assets; adjust Swing for signal frequency, tolerance for plateau sensitivity.
Ideal Use Cases
Swing trading on 1m–1h charts for entries/exits aligned with HTF trends.
Identifying support/resistance in ranging markets via plateaus.
Scalping with short lookbacks or longer swings with HTF enabled.
Manual or alert-based trading on futures, stocks, or forex.
Why It's Valuable
This indicator builds on ceyhun's core TSL logic with practical enhancements for modern trading: clutter reduction via expiration/decay, visual customization, and plateau-based S/R for better context. It promotes disciplined, trend-aware decisions while maintaining simplicity.
Note: Optimized for any timeframe/asset; test in demo. Not financial advice—use with risk management.
The TSL Drunken Bird is an enhanced technical analysis tool for swing traders on TradingView, based on the original Accurate Swing Trading System by ceyhun. It generates buy and sell signals when price crosses a dynamic Trailing Stop Loss (TSL) level derived from recent highs and lows. This version introduces plateau detection for support and resistance lines, dynamic label expiration to reduce clutter, customizable line styles and decay, and improved HTF confluence for trend-aligned trading. Visual elements include signal labels, horizontal lines, a colored TSL plot, and optional bar/background coloring. Alerts are available for buy/sell crossovers, making it suitable for assets like NASDAQ E-mini futures, stocks, forex, and more.
This script adapts and expands upon ceyhun's original codetradingview.com, adding significant features such as tolerance-based plateau identification for support/resistance, label management with timeframe-aware expiration (~7 days), cross-count decay for lines, and expanded customization options. Inspiration for the support and resistance plateau lines came from AnotherDAPTrader. Released under the Mozilla Public License 2.0.Key
Features
Swing Signals: "BUY" and "SELL" labels on price crossovers/crossunders of the TSL, with a user-defined lookback (default 3).
HTF Confluence: Filters signals based on higher timeframe trend (e.g., "EXIT LONG" instead of "SELL" if HTF is bullish); toggleable.
HTF Options: Select from 5m, 15m, 30m, 1h, 4h, Daily, Weekly, or Monthly.
Plateau Detection: Identifies flat highs/lows (with tolerance) for resistance/support lines, plotted as dotted/solid/dashed with customizable colors, thickness, and decay after crosses (default 2).
Horizontal Lines: Green (buy) and red (sell) lines at signal closes, extending right until crossed; toggle between short (no extension limit) or long visualization.
TSL Visualization: Colored line (green if close >= TSL, red otherwise) for dynamic levels.
Bar/Background Coloring: Optional green/red coloring based on price vs. TSL.
Label Expiration: All labels (signals and plateaus) auto-delete after ~7 days (timeframe-adjusted, default 1008 bars).
Alerts: Triggers for "Buy Signal" and "Sell Signal" on crossovers.
How to Use
Add to Chart: Paste the Pine Script into TradingView's editor and add to your chart.
Configure Settings:
Swing: Lookback for highs/lows (min 1).
Plateau Tolerance: Flatness allowance (default 0.0).
Use HTF Confluence: Enable for trend filtering.
Higher Time Frame: Choose timeframe string.
Barcolor/Bgcolor: Toggle coloring.
Show Plateau Lines: Enable support/resistance.
Line Styles/Colors/Thickness: Customize buy/sell and plateau visuals.
Plateau Line Decay: Crosses before stopping extension.
Label Expiration: Bars for auto-deletion (~7 days).
Interpret Elements:
Labels: "BUY"/"SELL" (green/red), "EXIT SHORT"/"EXIT LONG" (orange) on signals; "Res"/"Sup" on plateaus.
Lines: Extend right until conditions met (cross for buy/sell, decay threshold for plateaus).
TSL Plot: Monitors trend shifts.
Set Alerts: Use "Buy Signal" or "Sell Signal" conditions for notifications.
Testing: Apply to volatile assets; adjust Swing for signal frequency, tolerance for plateau sensitivity.
Ideal Use Cases
Swing trading on 1m–1h charts for entries/exits aligned with HTF trends.
Identifying support/resistance in ranging markets via plateaus.
Scalping with short lookbacks or longer swings with HTF enabled.
Manual or alert-based trading on futures, stocks, or forex.
Why It's Valuable
This indicator builds on ceyhun's core TSL logic with practical enhancements for modern trading: clutter reduction via expiration/decay, visual customization, and plateau-based S/R for better context. It promotes disciplined, trend-aware decisions while maintaining simplicity.
Note: Optimized for any timeframe/asset; test in demo. Not financial advice—use with risk management.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
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 sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
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.