OPEN-SOURCE SCRIPT
TSL Drunken Bird

A huge shoutout to anotherDAPTrader for inspiration and support in developing this system!
Overview:
The Accurate Swing Trading System is a powerful technical analysis tool designed for swing traders on TradingView. It generates precise buy and sell signals based on price action crossing a dynamic Trailing Stop Loss (TSL) level, calculated from recent highs and lows. Enhanced with optional Higher Time Frame (HTF) confluence, the system aligns short-term signals with broader market trends, making it ideal for traders seeking to optimize entries and exits. Visual indicators include signal labels, customizable horizontal lines, a colored TSL line, and optional bar/background coloring. Alerts support trade execution across various assets, such as NASDAQ E-mini futures, stocks, forex, and more. A special shoutout to AnotherDAPTrader for inspiration and support in developing this system!
Key Features:
Swing Signals: Generates "BUY" and "SELL" signals when the closing price crosses above/below the TSL, based on a user-defined lookback period (Swing).
HTF Confluence: Adjusts signals based on the HTF trend (e.g., "EXIT LONG" instead of "SELL" if HTF is bullish), toggleable via Use HTF Confluence.
HTF Selection: Choose from 8 timeframes: 5-minute, 15-minute, 30-minute, 1-hour, 4-hour, Daily, Weekly, or Monthly.
Horizontal Lines: Plots green (buy) and red (sell) lines at the closing price of signal bars, with a toggle to extend lines 50 or 500 bars.
TSL Visualization: Displays a TSL line (green if close >= TSL, red if close < TSL) to highlight dynamic support/resistance levels.
Bar/Background Coloring: Optionally colors candlesticks and chart background green (bullish) or red (bearish) based on price relative to TSL.
Alerts: Configurable alerts for "Buy Signal" and "Sell Signal" on price crossovers/crossunders.
Persistent Behavior: All components (signals, labels, lines, TSL, coloring) remain on the chart indefinitely, consistent with the original design.
Use Cases:
Perfect for swing trading on any timeframe (e.g., 1-minute for scalping, 1-hour for swing trading) and asset (e.g., NASDAQ E-mini futures, stocks, forex).
Enhances decision-making by aligning short-term trades with higher timeframe trends.
Supports both manual trading (via visual cues) and automated trading (via alerts).
License:
Released under the Mozilla Public License 2.0. Created by ceyhun, with a shoutout to AnotherDAPTrader.
How to Use the Accurate Swing Trading System in TradingView
Add the Script to TradingView:
Open TradingView (tradingview.com) in a browser or desktop app.
Navigate to the Pine Editor (bottom panel of any chart).
Copy and paste the provided Pine Script code.
Click "Add to Chart" to apply the indicator to your active chart.
Configure Indicator Settings:
Access settings by clicking the gear icon next to the indicator name on the chart.
Adjust the following inputs:
Swing (default: 3): Defines the lookback period for calculating the highest high and lowest low used in the TSL. Higher values produce smoother but potentially delayed signals.
Barcolor (default: true): Enables/disables green (bullish) or red (bearish) candlestick coloring based on close vs. TSL.
Bgcolor (default: false): Enables/disables green/red background coloring for trend visualization.
Use HTF Confluence (default: true): Enables/disables HTF trend filtering. When enabled, signals adjust to reflect HTF trend (e.g., "EXIT LONG" for sell signals if HTF is bullish).
Higher Time Frame (default: "60"): Select from ["5", "15", "30", "60", "240", "D", "W", "M"] for 5-minute, 15-minute, 30-minute, 1-hour, 4-hour, Daily, Weekly, or Monthly HTF analysis.
Use Long Horizontal Lines (500 bars) (default: true): Toggles horizontal line length between 500 bars (long) and 50 bars (short).
Interpret Signals and Visuals:
Signal Labels:
"BUY" (green, below bar): Triggered when close crosses above TSL (and HTF is bullish or use_htf is off).
"SELL" (red, above bar): Triggered when close crosses below TSL (and HTF is bearish or use_htf is off).
"EXIT SHORT" (orange, below bar): Triggered on buy signals when HTF is bearish (with use_htf on).
"EXIT LONG" (orange, above bar): Triggered on sell signals when HTF is bullish (with use_htf on).
Horizontal Lines:
Green lines (buy signals) and red lines (sell signals) are plotted at the close price of the trigger bar, aligning with TSL color changes (green to red or vice versa).
Lines extend 50 bars (if long_lines is false) or 500 bars (if true) to the right.
TSL Line: A continuous line (linewidth=3) showing the TSL level, colored green (close >= TSL) or red (close < TSL).
Bar/Background Coloring: If enabled, candlesticks and background are colored green (bullish) or red (bearish) based on close vs. TSL.
Set Up Alerts:
Right-click the indicator name on the chart and select "Add Alert."
Choose "Buy Signal" or "Sell Signal" as the condition.
Configure alert settings (e.g., notification method, frequency: once per bar, etc.).
Alerts trigger on Buy (crossover) or Sell (crossunder) events, ideal for trade execution or monitoring.
Test on a Chart:
Apply to a chart (e.g., NASDAQ E-mini futures, 1-minute timeframe, as per your metadata from July 10, 2025, 05:41 PM CDT).
Verify:
Labels: "BUY", "SELL", "EXIT LONG", "EXIT SHORT" appear only on crossover/crossunder bars.
Horizontal Lines: Green/red lines plot at the close price where TSL changes color (green to red for Sell, red to green for Buy), extending 50 or 500 bars based on long_lines.
TSL Line: Updates continuously, colored green/red based on close vs. TSL.
Coloring: Bar/background coloring (if enabled) reflects trend direction.
HTF Confluence: With use_htf on, test htf_res = "M" (and others like "60", "D") to ensure signals adjust correctly (e.g., "EXIT LONG" for sell signals if monthly HTF is bullish).
Alerts: Confirm alerts trigger on crossovers/crossunders.
Ensure all components persist indefinitely (no decay).
Best Practices:
Timeframe: Use on any timeframe (e.g., 1m for scalping, 1h for swing trading). Adjust Swing to balance signal frequency and reliability.
Asset: Suitable for volatile assets like NASDAQ E-mini futures, stocks, or forex.
HTF Alignment: Enable use_htf for trend-aligned trades, especially on higher timeframes like "D" or "M".
Line Length: Use long_lines = true for longer-term visualization (500 bars) or false for shorter-term (50 bars).
Risk Management: Combine with stop-loss/take-profit levels and proper position sizing, as the system does not include risk management.
Acknowledgments:
License Note:
This script is provided under the Mozilla Public License 2.0. Users are free to use, modify, and distribute it per the license terms.
Overview:
The Accurate Swing Trading System is a powerful technical analysis tool designed for swing traders on TradingView. It generates precise buy and sell signals based on price action crossing a dynamic Trailing Stop Loss (TSL) level, calculated from recent highs and lows. Enhanced with optional Higher Time Frame (HTF) confluence, the system aligns short-term signals with broader market trends, making it ideal for traders seeking to optimize entries and exits. Visual indicators include signal labels, customizable horizontal lines, a colored TSL line, and optional bar/background coloring. Alerts support trade execution across various assets, such as NASDAQ E-mini futures, stocks, forex, and more. A special shoutout to AnotherDAPTrader for inspiration and support in developing this system!
Key Features:
Swing Signals: Generates "BUY" and "SELL" signals when the closing price crosses above/below the TSL, based on a user-defined lookback period (Swing).
HTF Confluence: Adjusts signals based on the HTF trend (e.g., "EXIT LONG" instead of "SELL" if HTF is bullish), toggleable via Use HTF Confluence.
HTF Selection: Choose from 8 timeframes: 5-minute, 15-minute, 30-minute, 1-hour, 4-hour, Daily, Weekly, or Monthly.
Horizontal Lines: Plots green (buy) and red (sell) lines at the closing price of signal bars, with a toggle to extend lines 50 or 500 bars.
TSL Visualization: Displays a TSL line (green if close >= TSL, red if close < TSL) to highlight dynamic support/resistance levels.
Bar/Background Coloring: Optionally colors candlesticks and chart background green (bullish) or red (bearish) based on price relative to TSL.
Alerts: Configurable alerts for "Buy Signal" and "Sell Signal" on price crossovers/crossunders.
Persistent Behavior: All components (signals, labels, lines, TSL, coloring) remain on the chart indefinitely, consistent with the original design.
Use Cases:
Perfect for swing trading on any timeframe (e.g., 1-minute for scalping, 1-hour for swing trading) and asset (e.g., NASDAQ E-mini futures, stocks, forex).
Enhances decision-making by aligning short-term trades with higher timeframe trends.
Supports both manual trading (via visual cues) and automated trading (via alerts).
License:
Released under the Mozilla Public License 2.0. Created by ceyhun, with a shoutout to AnotherDAPTrader.
How to Use the Accurate Swing Trading System in TradingView
Add the Script to TradingView:
Open TradingView (tradingview.com) in a browser or desktop app.
Navigate to the Pine Editor (bottom panel of any chart).
Copy and paste the provided Pine Script code.
Click "Add to Chart" to apply the indicator to your active chart.
Configure Indicator Settings:
Access settings by clicking the gear icon next to the indicator name on the chart.
Adjust the following inputs:
Swing (default: 3): Defines the lookback period for calculating the highest high and lowest low used in the TSL. Higher values produce smoother but potentially delayed signals.
Barcolor (default: true): Enables/disables green (bullish) or red (bearish) candlestick coloring based on close vs. TSL.
Bgcolor (default: false): Enables/disables green/red background coloring for trend visualization.
Use HTF Confluence (default: true): Enables/disables HTF trend filtering. When enabled, signals adjust to reflect HTF trend (e.g., "EXIT LONG" for sell signals if HTF is bullish).
Higher Time Frame (default: "60"): Select from ["5", "15", "30", "60", "240", "D", "W", "M"] for 5-minute, 15-minute, 30-minute, 1-hour, 4-hour, Daily, Weekly, or Monthly HTF analysis.
Use Long Horizontal Lines (500 bars) (default: true): Toggles horizontal line length between 500 bars (long) and 50 bars (short).
Interpret Signals and Visuals:
Signal Labels:
"BUY" (green, below bar): Triggered when close crosses above TSL (and HTF is bullish or use_htf is off).
"SELL" (red, above bar): Triggered when close crosses below TSL (and HTF is bearish or use_htf is off).
"EXIT SHORT" (orange, below bar): Triggered on buy signals when HTF is bearish (with use_htf on).
"EXIT LONG" (orange, above bar): Triggered on sell signals when HTF is bullish (with use_htf on).
Horizontal Lines:
Green lines (buy signals) and red lines (sell signals) are plotted at the close price of the trigger bar, aligning with TSL color changes (green to red or vice versa).
Lines extend 50 bars (if long_lines is false) or 500 bars (if true) to the right.
TSL Line: A continuous line (linewidth=3) showing the TSL level, colored green (close >= TSL) or red (close < TSL).
Bar/Background Coloring: If enabled, candlesticks and background are colored green (bullish) or red (bearish) based on close vs. TSL.
Set Up Alerts:
Right-click the indicator name on the chart and select "Add Alert."
Choose "Buy Signal" or "Sell Signal" as the condition.
Configure alert settings (e.g., notification method, frequency: once per bar, etc.).
Alerts trigger on Buy (crossover) or Sell (crossunder) events, ideal for trade execution or monitoring.
Test on a Chart:
Apply to a chart (e.g., NASDAQ E-mini futures, 1-minute timeframe, as per your metadata from July 10, 2025, 05:41 PM CDT).
Verify:
Labels: "BUY", "SELL", "EXIT LONG", "EXIT SHORT" appear only on crossover/crossunder bars.
Horizontal Lines: Green/red lines plot at the close price where TSL changes color (green to red for Sell, red to green for Buy), extending 50 or 500 bars based on long_lines.
TSL Line: Updates continuously, colored green/red based on close vs. TSL.
Coloring: Bar/background coloring (if enabled) reflects trend direction.
HTF Confluence: With use_htf on, test htf_res = "M" (and others like "60", "D") to ensure signals adjust correctly (e.g., "EXIT LONG" for sell signals if monthly HTF is bullish).
Alerts: Confirm alerts trigger on crossovers/crossunders.
Ensure all components persist indefinitely (no decay).
Best Practices:
Timeframe: Use on any timeframe (e.g., 1m for scalping, 1h for swing trading). Adjust Swing to balance signal frequency and reliability.
Asset: Suitable for volatile assets like NASDAQ E-mini futures, stocks, or forex.
HTF Alignment: Enable use_htf for trend-aligned trades, especially on higher timeframes like "D" or "M".
Line Length: Use long_lines = true for longer-term visualization (500 bars) or false for shorter-term (50 bars).
Risk Management: Combine with stop-loss/take-profit levels and proper position sizing, as the system does not include risk management.
Acknowledgments:
License Note:
This script is provided under the Mozilla Public License 2.0. Users are free to use, modify, and distribute it per the license terms.
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.