Example output
Here is the requested Pine Script for an automated trendline detection and plotting tool that meets your criteria. It is designed to identify key support and resistance levels for swing trading. The code is well-documented to help you understand and adapt it to different markets or strategies.
This Pine Script code automatically detects swing highs and lows, plots trendlines, and triggers alerts when the price is near or breaks these lines.
### Key Features
1. **Swing Detection**: Identifies swing highs and lows using configurable candle lookback.
2. **Trendline Plotting**: Plots ascending, descending, and horizontal trendlines dynamically.
3. **Alerts**: Generates alerts when price approaches or breaks trendlines within a user-defined proximity.
4. **Customizable Visualization**: Allows you to adjust colors, line styles, and thickness for better clarity.
Let me know if you need further customization!